...

/

Developing the Data Accessing Logic

Developing the Data Accessing Logic

Learn to create a data access layer with an in-memory database in a Deno web application.

Define the types

We need a database or something that looks like one to transform what we wrote previously into a fully functioning app. We need something that can store and retrieve a list of museums. Let’s create that now.

Press + to interact

While developing the controller, we noticed that we needed something that would be able to get the data, that is, the repository. This module will abstract all the calls to a data source, such as the data source that stores the museums. It will have a very well-defined set of methods, and whoever wants to access the data should do so through this module.

We already have part of its interface defined inside src/museums/types.ts, so let’s write a class that implements it. For now, we won’t connect it to a real database. We will use an ES6 Map as an in-memory database instead.

Steps for developing data access logic

Let’s ...