jerni a framework to build data-driven products from the ground up
Type: | MongoDbReadModel |
Namespace: | @jerni/store-mongo |
Extends: | jerni::DataModel |
Description: | Encapsulate projection logic for a MongoDB Collection |
Properties
transform:
(UncommittedEvent) => Promise<MongoDbOperation[]>
functionally transfrom an event into a list of MongoDB write operations. This will not have the ability to read the event's ID
collectionName:
string
getter for the underlaying collection name
Examples
file: journey/models/users.js
const { Model } = require("@jerni/store-mongo");const userModel = new Model({name: "users",version: "3",transform(event) { /* ... */ }});console.log(userModel.collectionName);
Output
"users_v3"
inherited from jerni::DataModel
name
: string
name of the model. Usually used to name the underlaying storage structure
inherited from jerni::DataModel
version
: string
version of the model. This enables the ability to run multiple versions of a model to avoid down-time in migrations