js-data

Respect Your Data

Give your data the treatment it deserves with a framework-agnostic, datastore-agnostic JavaScript ORM built for ease of use and peace of mind. Works in Node.js and in the Browser.

Get Started

Data Mapper Pattern

Concepts

Data Mapper Pattern

The Data Mapper Pattern is an architectural pattern introduced by Martin Fowler in his book Patterns of Enterprise Application Architecture. A Data Mapper is a type of Data Access Layer that performs bi-directional transfer of data between objects in memory and persistent storage. With the Data Mapper Pattern, the in-memory objects have no idea there is a database, and the database schema is unaware of any objects that use it. This separation is the main purpose of a Data Mapper.

👍

Tip

An individual Data Mapper moves data between objects in memory and a database while keeping the objects and the database ignorant of each other, and while keeping the data independent of the Data Mapper itself.

🚧

Caution

You've almost certainly heard the terms Model and Resource used in relation to data management. These are heavily overloaded terms and are avoided in this documentation to prevent confusion. JSData components have specific names that aim to unambiguously describe their function.

JSData implements the Data Mapper Pattern with a Mapper component. Mapper is a constructor function. Instantiating Mapper gives you a new Mapper instance capable of executing JSData's core ORM functionality. The user.json example above describes several MySQL tables: users, phone_numbers, profiles, and organizations. To perform CRUD operations against these four tables one would need four Mapper instances—one for each table.

👍

Tip

Rather than manually instantiating and managing potentially dozens or hundreds of Mapper instances, JSData provides a Container component which will manage Mapper instances for you.

Read the API docs for the Mapper and Container components.

Updated 4 years ago


Data Mapper Pattern


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.