Write Model
Types
event
An event can have an arbitrary data structure, as long as the reducer understand how to parse it.
commit
Commits contain one or more events. Adapters must return commits in the following format:
attribute | type | description |
|
| ID of the entity |
|
| Version number of the commit |
|
| Entity name |
|
| Unique ID for this commit |
|
| Array of event objects included in the commit |
Methods
listCommits
listCommits(commitId='0')
Loads all commits for all entities, (optionally) starting from a specific commitId
Parameters
attribute | type | description |
|
| A commit ID to start from (inclusive). Default |
Returns
[ commits ]
- an array of commit objects.
loadEvents
loadEvents(id, version=0)
Loads all events for a given entity, (optionally) starting from a commit version
.
Parameters
attribute | type | description |
|
| (required) the ID of the entity |
|
| a commit version number to start from (inclusive). Defaults to |
Returns
[ events ]
- a flat array of event objects.
append
append(id, version, events)
Creates a new commit and persists it to the database. Must throw if a commit with the same id
+ version
already exists.
Parameters
attribute | type | description |
|
| (required) the ID of the entity |
|
| (required) the commit version number |
|
| (required) an array of |
Returns
null
Last updated