interface ds.DataStore
Abstraction around data storage in the form of document style records.
Eventicle contains a built in InMemoryDatastore. Others can be imported as needed.
Methods
createEntity(workspaceId, type, content)
Create a new entity in the datastore.
Name | Type | Description |
---|---|---|
|
|
Tenant |
|
|
Entity type or "table" name |
|
|
|
Returns |
|
createEntity(workspaceId: string, type: string, content: any): Promise<Record>;
deleteEntity(workspaceId, type, id)
Remove a single Record by its ID
Name | Type | Description |
---|---|---|
|
|
The tenant |
|
|
the record type |
|
|
the id of the entity. |
Returns |
|
deleteEntity(workspaceId: string, type: string, id: string): Promise<void>;
deleteMany(workspaceId, type, query)
Delete multiple from the Datastore via a result
Name | Type | Description |
---|---|---|
|
|
the tenant |
|
|
the Record type |
|
The query, any matching Records will be deleted. |
|
Returns |
|
deleteMany(workspaceId: string, type: string, query: Query): Promise<void>;
findEntity(workspaceId, type, query, sorting)
Find using a given , and optionally sort the results using a
Name | Type | Description |
---|---|---|
|
|
|
|
|
Entity type or "table" name |
|
Json object to match fields |
|
|
||
Returns |
|
findEntity(workspaceId: string, type: any, query: Query, sorting?: DataSorting): Promise<Record[]>;
findEntityPaginated(workspaceId, type, query, sorting, page, pageSize)
Find using a given , and optionally sort the results using a , with pagination information provided in
Name | Type | Description |
---|---|---|
|
|
The tenant id. |
|
|
Entity type or "table" name |
|
Json object to match fields |
|
|
How to sort the results |
|
|
|
page count |
|
|
page size |
Returns |
|
findEntityPaginated(workspaceId: string, type: string, query: Query, sorting: DataSorting, page: number, pageSize: number): Promise<PagedRecords>;
getEntity(workspaceId, type, id)
Look up a single by its ID
Name | Type | Description |
---|---|---|
|
|
when running on a multi-tenant Datastore, selects the tenant. |
|
|
The type of the Record |
|
|
The record ID |
Returns |
|
getEntity(workspaceId: string, type: string, id: string): Promise<Record>;
getTransactionData()
Bag of data associated with the current transaction
getTransactionData(): TransactionData;
hasTransactionData()
Whether transaction data currently exists in this context.
hasTransactionData(): boolean;
on(event, listener)
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
Returns |
|
on(event: 'transaction.start', listener: (name: string, data: TransactionData) => void): this;
on(event, listener)
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
Returns |
|
on(event: 'transaction.commit', listener: (name: string, data: TransactionData) => void): this;
saveEntity(workspaceId, type, item)
Save updates an existing entity
Name | Type | Description |
---|---|---|
|
|
The tenant |
|
|
the record type |
|
|
The existing Record. Must have come from or |
Returns |
|
saveEntity(workspaceId: string, type: string, item: Record): Promise<Record>;
transaction(exec, options)
Open a transaction (or optionally join one if it exists)
Name | Type | Description |
---|---|---|
|
|
transaction is open within this execution. Once this function promise resolves, the transaction is committed or rolled back If |
|
if exists, controls if the trnasction should be new, or an existing on can be used. |
|
Returns |
|
transaction<T>(exec: () => Promise<T>, options?: TransactionOptions): Promise<T>;