bpmn-server / DocumentQuery
Class: DocumentQuery#
Evaluates the engine's MongoDB-style queries, projections, sorts and updates over plain JSON documents: the shared semantics of every non-MongoDB IDocumentStore (the in-memory store; adapters that keep documents as JSON in another database). An operator it does not know is refused, never ignored.
Table of contents#
Constructors#
Methods#
- matches
- values
- first
- list
- isOperatorObject
- candidates
- matchCondition
- comparable
- equal
- compare
- project
- sort
- apply
- seed
- indexKey
Constructors#
constructor#
• new DocumentQuery(): DocumentQuery
Returns#
Methods#
matches#
▸ matches(doc, query): boolean
Parameters#
| Name | Type |
|---|---|
doc |
any |
query |
StorageQuery |
Returns#
boolean
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:11
values#
▸ values(doc, path): any[]
The values at a dotted path, descending into arrays (as MongoDB does): every value reached, arrays included
as themselves. An array's element that lacks the field gives undefined, so { 'items.assignee': null }
matches an item without an assignee, as in MongoDB, whether the field is absent or undefined.
Parameters#
| Name | Type |
|---|---|
doc |
any |
path |
string |
Returns#
any[]
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:30
first#
▸ first(doc, path): any
The first value at a path that is there: what a sort or a unique index is keyed by.
Parameters#
| Name | Type |
|---|---|
doc |
any |
path |
string |
Returns#
any
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:48
list#
▸ list(condition, operator): StorageQuery[]
Parameters#
| Name | Type |
|---|---|
condition |
any |
operator |
string |
Returns#
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:52
isOperatorObject#
▸ isOperatorObject(condition): boolean
Parameters#
| Name | Type |
|---|---|
condition |
any |
Returns#
boolean
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:57
candidates#
▸ candidates(values): any[]
Each value, and each element of an array value: what an equality or comparison is tried against.
Parameters#
| Name | Type |
|---|---|
values |
any[] |
Returns#
any[]
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:63
matchCondition#
▸ matchCondition(values, condition): boolean
Parameters#
| Name | Type |
|---|---|
values |
any[] |
condition |
any |
Returns#
boolean
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:69
comparable#
▸ comparable(value): any
Parameters#
| Name | Type |
|---|---|
value |
any |
Returns#
any
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:95
equal#
▸ equal(a, b): boolean
Parameters#
| Name | Type |
|---|---|
a |
any |
b |
any |
Returns#
boolean
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:101
compare#
▸ compare(a, b): number
Parameters#
| Name | Type |
|---|---|
a |
any |
b |
any |
Returns#
number
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:109
project#
▸ project(doc, projection): any
Parameters#
| Name | Type |
|---|---|
doc |
any |
projection |
Record\<string, any> |
Returns#
any
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:114
sort#
▸ sort(docs, sort): any[]
Parameters#
| Name | Type |
|---|---|
docs |
any[] |
sort |
Record\<string, -1 | 1> |
Returns#
any[]
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:133
apply#
▸ apply(doc, update): any
update applied to doc: $set (dotted paths create objects), $unset, $inc, $push; a document without operators replaces it (its _id kept).
Parameters#
| Name | Type |
|---|---|
doc |
any |
update |
Record\<string, any> |
Returns#
any
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:146
seed#
▸ seed(query): any
The document an upsert inserts: the query's plain equality fields, then the update.
Parameters#
| Name | Type |
|---|---|
query |
StorageQuery |
Returns#
any
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:169
indexKey#
▸ indexKey(doc, fields): string
The values a unique index is keyed by, or null when the document has none of its fields.
Parameters#
| Name | Type |
|---|---|
doc |
any |
fields |
string[] |
Returns#
string
Defined in#
packages/bpmn-server/src/datastore/DocumentQuery.ts:176