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.
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.
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 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:
organizations. To perform CRUD operations against these four tables one would need four
Mapper instances—one for each table.
Rather than manually instantiating and managing potentially dozens or hundreds of
Mapperinstances, JSData provides a
Containercomponent which will manage
Mapperinstances for you.
Updated 4 years ago