class InMemoryDatastore

In memory Datastore implementation.

This is suitable for testing and single instance demonstration purposes.

Properties

events

Signature
events: EventEmitter<[never]>;

Methods

createEntity(workspaceId, type, item)

Parameters
Name Type Description

workspaceId

string

type

string

Entity type or "table" name

item

any

Returns

Promise<any>

Signature
createEntity(workspaceId: string, type: string, item: any): Promise<any>;

deleteEntity(workspaceId, type, id)

Parameters
Name Type Description

workspaceId

string

type

string

id

string

Returns

Promise<void>

Signature
deleteEntity(workspaceId: string, type: string, id: string): Promise<void>;

deleteMany(workspaceId, type, query)

Parameters
Name Type Description

workspaceId

string

type

string

query

Query

Returns

Promise<void>

Signature
deleteMany(workspaceId: string, type: string, query: Query): Promise<void>;

findEntity(workspaceId, type, query, sorting)

Parameters
Name Type Description

workspaceId

string

type

any

Entity type or "table" name

query

Query

Json object to match fields

sorting

DataSorting

Returns

Promise<Record[]>

Signature
findEntity(workspaceId: string, type: any, query: Query, sorting?: DataSorting): Promise<Record[]>;

findEntityPaginated(workspaceId, type, query, sorting, page, pageSize)

Parameters
Name Type Description

workspaceId

string

type

string

Entity type or "table" name

query

Query

Json object to match fields

sorting

DataSorting

page

number

page count

pageSize

number

page size

Returns

Promise<PagedRecords>

Signature
findEntityPaginated(workspaceId: string, type: string, query: Query, sorting: DataSorting, page: number, pageSize: number): Promise<PagedRecords>;

getEntity(workspaceId, type, id)

Parameters
Name Type Description

workspaceId

string

type

any

Entity type or "table" name

id

string

Returns

Promise<Record>

Signature
getEntity(workspaceId: string, type: any, id: string): Promise<Record>;

getTransactionData()

Signature
getTransactionData(): TransactionData;

hasTransactionData()

Signature
hasTransactionData(): boolean;

on(event, listener)

Parameters
Name Type Description

event

"transaction.start" | "transaction.commit"

listener

(name: string, data: TransactionData) => void

Returns

this

Signature
on(event: "transaction.start" | "transaction.commit", listener: (name: string, data: TransactionData) => void): this;

purge()

Signature
purge(): Promise<void>;

saveEntity(workspaceId, type, item)

Parameters
Name Type Description

workspaceId

string

type

string

item

Record

Returns

Promise<Record>

Signature
saveEntity(workspaceId: string, type: string, item: Record): Promise<Record>;

transaction(exec)

Parameters
Name Type Description

exec

() => Promise<T>

Returns

Promise<T>

Signature
transaction<T>(exec: () => Promise<T>): Promise<T>;