Storage
Standard Solid uses TypeORM to enable applications to store data in databases.
More information can be found in the TypeORM documentation, but a summarized overview can be found below.
Data Mapper
When using the Data Mapper framework, developers access the functionality of their data store through Repositories. Repositories perform bi-directional transfer of data between a persistent data store (often a relational database) and an in-memory data representation (the domain layer).
The goal of the Data Mapper pattern is to keep the in-memory representation and the persistent data store independent of each other and the data mapper itself (Repositories). This is useful when one needs to model and enforce strict business processes on the data in the domain layer that do not map neatly to the persistent data store.
Configuration
The default Data Mapper within Standard Solid is configured by the type-orm.json Components.js configuration. Override this default configuration by replacing it in your Components.js config file:
In your configuration do two things:
Set the
options
parameter to contain the type, location, and credentials for your database
Add some Entity Schemas. See the TypeORM documentation and the example repo configuration for reference:
Be sure to include this file in your index.ts
,
Usage
After adding the Entity Schemas and configurations, you can access repositories using the Data Mapper instance in your code:
Remember to add the Data Mapper as an parameter to any class instantiated in your Components.js configuration which needs to access data from your data store:
User Data
Solid integration coming soon!
Last updated