Skip to content

bpmn-server / MemoryDocumentStore

Class: MemoryDocumentStore#

An IDocumentStore in memory: for tests, and for a standalone engine that keeps nothing across restarts. Documents are copied in and out, so callers never share state with the store; unique indexes are enforced as MongoDB does. One instance may be shared by several servers to stand for one database they all use.

Implements#

Table of contents#

Constructors#

Properties#

Methods#

Constructors#

constructor#

• new MemoryDocumentStore(): MemoryDocumentStore

Returns#

MemoryDocumentStore

Properties#

collections#

• Private Readonly collections: Map\<string, any[]>

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:13


uniqueIndexes#

• Private Readonly uniqueIndexes: Map\<string, string[][]>

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:14

Methods#

name#

▸ name(database, collection): string

Parameters#

Name Type
database string
collection string

Returns#

string

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:16


docs#

▸ docs(database, collection): any[]

Parameters#

Name Type
database string
collection string

Returns#

any[]

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:17


find#

▸ find(database, collection, query, projection?, sort?): Promise\<any[]>

Documents of collection matching query, projected and sorted. database names the logical database (MongoDB's db name; ignored by single-database adapters).

Parameters#

Name Type Default value
database string undefined
collection string undefined
query StorageQuery undefined
projection Record\<string, any> null
sort Record\<string, -1 | 1> null

Returns#

Promise\<any[]>

Implementation of#

IDocumentStore.find

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:23


count#

▸ count(database, collection, query): Promise\<number>

How many documents of collection match query. Optional: without it, callers count what find returns.

Parameters#

Name Type
database string
collection string
query StorageQuery

Returns#

Promise\<number>

Implementation of#

IDocumentStore.count

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:28


insert#

▸ insert(database, collection, documents): Promise\<number>

Inserts all of documents, or none: a unique-index conflict throws a DuplicateKeyError; any other failure throws as it is. Returns how many were inserted.

Parameters#

Name Type
database string
collection string
documents any[]

Returns#

Promise\<number>

Implementation of#

IDocumentStore.insert

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:32


update#

▸ update(database, collection, query, update, options?): Promise\<number>

Updates the first document matching query ($set fields, or replaces it); { upsert: true } inserts when none matches. Returns how many were modified.

Parameters#

Name Type
database string
collection string
query StorageQuery
update Record\<string, any>
options Object
options.upsert? boolean

Returns#

Promise\<number>

Implementation of#

IDocumentStore.update

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:40


remove#

▸ remove(database, collection, query): Promise\<{ deletedCount: number }>

Removes every document matching query; returns { deletedCount }.

Parameters#

Name Type
database string
collection string
query StorageQuery

Returns#

Promise\<{ deletedCount: number }>

Implementation of#

IDocumentStore.remove

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:54


createIndex#

▸ createIndex(database, collection, index, options?): Promise\<string>

Declares an index; { unique: true } makes insert refuse a second document with the same values. Idempotent.

Parameters#

Name Type
database string
collection string
index Record\<string, -1 | 1>
options Object
options.unique? boolean

Returns#

Promise\<string>

Implementation of#

IDocumentStore.createIndex

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:61


close#

▸ close(): Promise\<void>

Releases connections. Idempotent.

Returns#

Promise\<void>

Implementation of#

IDocumentStore.close

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:73


assertUnique#

▸ assertUnique(database, collection, others, doc): void

Parameters#

Name Type
database string
collection string
others any[]
doc any

Returns#

void

Defined in#

packages/bpmn-server/src/datastore/MemoryDocumentStore.ts:75

Comments