Merge remote-tracking branch 'origin/develop' into ref-resolvers

This commit is contained in:
SamTolmay 2021-08-17 12:40:35 +02:00
commit 96ebc0e273
No known key found for this signature in database
GPG Key ID: 655CB3F5AA745CF8
14 changed files with 3058 additions and 117 deletions

View File

@ -10,16 +10,448 @@
- id: properties.style
type: List
properties:
style:
style:
border: 1px solid blue
- id: properties.style-two-items
type: List
properties:
style:
style:
border: 1px solid blue
blocks:
- id: one
type: Test
- id: two
type: Test
- id: properties.direction is row
type: List
properties:
direction: row
style:
border: 1px solid blue
blocks:
- id: one
type: Test
- id: two
type: Test
- id: properties.direction is column
type: List
properties:
direction: column
style:
border: 1px solid blue
blocks:
- id: one
type: Test
- id: two
type: Test
- id: properties.direction is row with default wrap
type: List
properties:
direction: row
style:
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test
- id: properties.direction is row and with wrap
type: List
properties:
direction: row
wrap: wrap
style:
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test
- id: properties.direction is row with wrap-reverse
type: List
properties:
direction: row
wrap: wrap-reverse
style:
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test
- id: properties.direction is row with no wrap
type: List
properties:
direction: row
wrap: nowrap
style:
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test
- id: properties.direction is row with no wrap and scroll
type: List
properties:
direction: row
wrap: nowrap
scroll: true
style:
width: 950px
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test
- id: properties.direction is row with no wrap and scroll false
type: List
properties:
direction: row
wrap: nowrap
scroll: false
style:
width: 950px
border: 1px solid blue
blocks:
- id: 1
type: Test
- id: 2
type: Test
- id: 3
type: Test
- id: 4
type: Test
- id: 5
type: Test
- id: 6
type: Test
- id: 7
type: Test
- id: 8
type: Test
- id: 9
type: Test
- id: 10
type: Test
- id: 11
type: Test
- id: 12
type: Test
- id: 13
type: Test
- id: 14
type: Test
- id: 15
type: Test
- id: 16
type: Test
- id: 17
type: Test
- id: 18
type: Test
- id: 19
type: Test
- id: 20
type: Test
- id: 21
type: Test
- id: 22
type: Test
- id: 23
type: Test
- id: 24
type: Test
- id: 25
type: Test
- id: 26
type: Test
- id: 27
type: Test
- id: 28
type: Test
- id: 29
type: Test
- id: 30
type: Test

View File

@ -30,7 +30,19 @@ const List = ({ blockId, events, list, methods, properties }) => {
<Box
blockId={blockId}
events={events}
properties={{ style: properties.style }}
properties={{
style: {
...(properties.direction
? {
display: 'flex',
flexDirection: properties.direction,
flexWrap: properties.wrap ? properties.wrap : 'wrap',
overflow: properties.scroll ? 'auto' : 'visible',
}
: {}),
...properties.style,
},
}}
methods={methods}
content={{
content: () => list.map((item) => item.content()),

View File

@ -7,9 +7,23 @@
"type": "object",
"additionalProperties": false,
"properties": {
"direction": {
"type": "string",
"enum": ["row", "column", "row-reverse", "column-reverse"],
"description": "List content along a 'row' or down a 'column'. Applies the 'flex-direction' css property to the List block."
},
"wrap": {
"type": "string",
"enum": ["wrap", "nowrap", "wrap-reverse"],
"description": "Specifies wrapping style to be applied to List block as 'wrap', 'nowrap' or 'wrap-reverse'. Applies the 'flex-wrap' css property to the List block - defaults to 'wrap', requires List direction to be set."
},
"scroll": {
"type": "boolean",
"description": "Specifies whether scrolling should be applied to the List, can be true or false. Applies the 'overflow' css property to the List block - defaults to 'visible', requires List direction to be set."
},
"style": {
"type": "object",
"description": "Css style object to apply to List div.",
"description": "Css style object to apply to List block.",
"docs": {
"displayType": "yaml"
}

View File

@ -30,19 +30,31 @@ _ref:
description: |
The `JsAction` action is used to call a custom JavaScript function which was loaded onto the page using the `window.lowdefy.registerJsAction()` method. This JavaScript function can be asynchronous. See [Custom Code](/custom-code) for more details on how to register a new JavaScript action.
The returned result of the JavaScript function is accessible through the [`_actions`](/_actions) operator for subsequent action in the event action list.
The returned result of the JavaScript function is accessible through the [`_actions`](/_actions) operator for subsequent actions in the event action list.
#### JsAction function parameters
A `JsAction` function is called with a context object which includes all [`context` data objects](/context-and-state) as well as the list of `args` passed to the action.
A `JsAction` is called with a context object which includes all [`context` data objects](/context-and-state) as well as the list of `args` passed to the action.
```text
(context: {
user: object,
actions: object,
contextId: string,
global: object,
input: object,
pageId: string,
requests: object,
state: object,
urlQuery: object,
input: object,
user: object,
},
...args?: any[]): any
```
#### Using Lowdefy actions in a JsAction
The context passed to the custom JsAction function contains an object called `actions`. This object contains all the Lowdefy action functions like `SetState`, `Request`, and `CallMethod`. The functions can be called using the same parameters as when they are used directly in the Lowdefy configuration. Operators in these parameters are not evaluated.
params: |
###### object
- `name: string`: __Required__ - The registered name of the JavaScript function to call when the action is triggered.
@ -232,3 +244,38 @@ _ref:
}
}
```
##### Use Lowdefy SetState action:
```js
// file: /public/theAnswer.js
function theAnswer({actions}) {
// Think for a while...
return actions.SetState({ answer: 42 })
}
export default theAnswer;
```
##### Use Lowdefy Request action to loop over a list of requests:
```js
// file: /public/loopRequests.js
function loopRequests({ actions }, ...requestIds) {
return Promise.all(requestIds.map((id) => actions.Request(id)));
}
export default loopRequests;
```
```yaml
id: call_all_requests
type: Button
events:
onClick:
- id: loop_requests
type: JsAction
params:
name: loopRequests
args:
- request_1
- request_2
- request_3
```

View File

@ -28,6 +28,7 @@ _ref:
- Events are triggered when something happens on a page, like clicking a button or loading a page.
- A list of actions are executed sequentially by a triggered event.
- If an action errors, the actions that follow are skipped.
- Actions that are `async: true` will not executed sequentially nor stop the event if they error.
- Action errors can be handled by providing a list of `try` and `catch` actions to the event.
- Operators used in action `params` are evaluated right before the action is executed.
- The [`_actions`](/_actions)) operator is available for sequential actions to use the values returned from preceding actions in the chain.
@ -42,7 +43,9 @@ _ref:
Blocks can define _events_ which the block can trigger when something happens on the page, like a button being clicked, an input's value being modified or a page being loaded. Some examples are `onClick` on a [`Button`](/Button) or `onEnter` on a [`PageHeaderMenu`](/PageHeaderMenu) block.
_Actions_ are tasks that can be executed, like calling a request, linking to a new page or changing a value in state. An array of actions can be defined for a event on a block. If that event gets triggered, those actions will execute sequentially. If any actions error while executing, the actions that follow it won't be executed, however, `catch` actions chain can be defined on a event to trigger when a error in a chain of actions occurs.
_Actions_ are tasks that can be executed, like calling a request, linking to a new page or changing a value in state. An array of actions can be defined for a event on a block. If that event gets triggered, those actions will execute sequentially. If any actions error while executing, the actions that follow it won't be executed, however, `catch` actions chain can be defined on a event to trigger when an error in a chain of actions occurs.
Actions which are `async: true` are an exception to the sequential rule of the actions chain. These actions will be executed asynchronously and the next actions in the chain will not wait for them to finish. If any `async: true` action throws an error, the chain will not be stopped and the event will still be completed successfully.
Each action has an `id`, unique to that action chain, and a `type` field which are required.
@ -57,6 +60,7 @@ _ref:
- `id: string`: __Required__ - A identifier for the action. It must be unique within the action chain it is defined in.
- `type: string`: __Required__ - The action type to be used. It must be a valid action type.
- `skip: boolean`: The test that determines whether the action will be skipped or not. This is usually written as operators which evaluates to a `true` or `false`. __Operators are evaluated__.
- `async: boolean`: This determines whether the action will be evaluated asynchronously. Operators are __not__ evaluated on `async`.
- `messages: object`: __Operators are evaluated__.
- `error: boolean | string`: If `boolean`, whether an error message should be displayed if the action throws an error. Error messages are shown by default. If a `string`, the error message to show to the user.
- `loading: boolean | string`: If `boolean`, whether a loading message should be displayed while the action is executing. Loading messages are not shown by default. If a `string`, the loading message to show to the user.

View File

@ -64,6 +64,7 @@ _ref:
- `collection: string`: __Required__ - The name of the MongoDB collection.
- `read: boolean`: Default: `true` - Allow read operations like find on the collection.
- `write: boolean`: Default: `false` - Allow write operations like update on the collection.
- `options: object`: See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/interfaces/mongoclientoptions.html) for more information.
#### Examples
@ -105,14 +106,30 @@ _ref:
#### Properties
- `pipeline: object[]`: __Required__ - Array containing all the aggregation framework commands for the execution.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#aggregate) for more information. Supported settings are:
- `readPreference: string | object`: The read preference.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#aggregate) for more information. Supported settings are:
- `allowDiskUse: boolean`: Default: `false` - Allow disk use on the MongoDB server to store temporary results for the aggregation.
- `maxTimeMS: number`: Specifies a cumulative time limit in milliseconds for processing operations on the cursor.
- `authdb: string`: Specifies the authentication information to be used.
- `batchSize: number`: The number of documents to return per batch.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `bypassDocumentValidation: boolean`: Default: `false` - Allow driver to bypass schema validation in MongoDB 3.2 or higher.
- `checkKeys: boolean`: The serializer will check if keys are valid.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `comment: string`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the aggregation. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `dbName: string`: The database name.
- `explain: boolean`: Specifies to return the information on the processing of the pipeline.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: Add an index selection hint to an aggregation command.
- `ignoreUndefined: boolean`: Default: `true` - Serialize will not emit undefined fields.
- `let: object`: Specifies an object with a list of variables. This allows you to improve command readability by separating the variables from the query text.
- `maxAwaitTimeMS: number`: The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
- `maxTimeMS: number`: Specifies a cumulative time limit in milliseconds for processing operations on the cursor.
- `noResponse: boolean`: Admin command option.
- `readConcern: object`: Specifies the level of isolation for read operations.
- `readPreference: string | object`: The read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern to use with the $out or $merge stage.
#### Examples
@ -142,14 +159,27 @@ _ref:
#### Properties
- `filter: object`: __Required__ - The filter used to select the document to update.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#updateOne) for more information. Supported settings are:
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#deletemany) for more information. Supported settings are:
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `checkKeys: boolean`: Default: `false` - If true, will throw if bson documents start with $ or include a . in any key value.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `hint: object`: An optional hint for query optimization.
- `comment: string`: A user-provided comment to attach to this command.
- `dbName: string`: The database name.
- `explain: boolean`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: An optional hint for query optimization.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `j: boolean`: Specify a journal write concern.
- `w: number | string`: The write concern
- `wtimeout: number`: The write concern timeout.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `maxTimeMS: number`: Specifies a cumulative time limit in milliseconds for processing operations on the cursor.
- `noResponse: boolean`: Admin command option.
- `ordered: boolean`: If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: string | object`: The read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -171,14 +201,27 @@ _ref:
#### Properties
- `filter: object`: __Required__ - The filter used to select the document to update.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#updateOne) for more information. Supported settings are:
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#deleteone) for more information. Supported settings are:
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `checkKeys: boolean`: Default: `false` - If true, will throw if bson documents start with $ or include a . in any key value.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `hint: object`: An optional hint for query optimization.
- `comment: string`: A user-provided comment to attach to this command.
- `dbName: string`: The database name.
- `explain: boolean`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: An optional hint for query optimization.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `j: boolean`: Specify a journal write concern.
- `w: number | string`: The write concern
- `wtimeout: number`: The write concern timeout.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `maxTimeMS: number`: Specifies a cumulative time limit in milliseconds for processing operations on the cursor.
- `noResponse: boolean`: Admin command option.
- `ordered: boolean`: If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: string | object`: The read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -201,16 +244,43 @@ _ref:
#### Properties
- `query: object`: __Required__ - A MongoDB query object.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#find) for more information. Supported settings are:
- `limit: number`: Sets the limit of documents returned in the query.
- `sort array | object`: Set to sort the documents coming back from the query.
- `projection: object`: The fields to return in the query. Object of fields to either include or exclude (one of, not both), `{'a':1, 'b': 1}` or `{'a': 0, 'b': 0}`.
- `skip: number`: Set to skip N documents ahead in your query (useful for pagination).
- `hint: object`: Tell the query to use specific indexes in the query. Object of indexes to use, `{'_id':1}`.
- `comment: string`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `readPreference: string | object`: The preferred read preference.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the query.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#find) for more information. Supported settings are:
- `allowDiskUse: boolean`: Allows disk use for blocking sort operations exceeding 100MB memory. (MongoDB 3.2 or higher)
- `allowPartialResults: boolean`: For queries against a sharded collection, allows the command (or subsequent getMore commands) to return partial results, rather than an error, if one or more queried shards are available.
- `authdb: string`: Specifies the authentication information to be used.
- `awaitData: boolean`: Specify if the cursor is a tailable-await cursor. Requires `tailable` to be true.
- `batchSize: number`: Set the batchSize for the getMoreCommand when iterating over the query results.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `checkKeys: boolean`: The serializer will check if keys are valid.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `comment: string | object`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `dbName: string`: The database name.
- `explain: boolean`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: Tell the query to use specific indexes in the query. Object of indexes to use, `{'_id':1}`.
- `ignoreUndefined: boolean`: Default: `true` - Serialize will not emit undefined fields.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `limit: number`: Sets the limit of documents returned in the query.
- `max: object`: The exclusive upper bound for a specific index.
- `maxAwaitTimeMS: number`: The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `tailable` and `awaitData` to be true.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `min: object`: The inclusive lower bound for a specific index.
- `noCursorTimeout: boolean`: The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
- `noResponse: boolean`: Admin command option.
- `projection: object`: The fields to return in the query. Object of fields to either include or exclude (one of, not both), `{'a':1, 'b': 1}` or `{'a': 0, 'b': 0}`.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: string | object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `returnKey: boolean`: If true, returns only the index keys in the resulting documents.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `showRecordId: boolean`: Determine whether to return the record identifier for each document. If true, adds a field $recordId to the returned documents.
- `singleBatch: boolean`: Default: `false` - Determines whether to close the cursor after the first batch.
- `skip: number`: Set to skip N documents ahead in your query (useful for pagination).
- `sort: array | object`: Set to sort the documents coming back from the query.
- `tailable: boolean`: Specify if the cursor is tailable.
- `timeout: boolean`: Specify if the cursor can timeout.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -241,16 +311,43 @@ _ref:
#### Properties
- `query: object`: __Required__ - A MongoDB query object.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#find) for more information. Supported settings are:
- `limit: number`: Sets the limit of documents returned in the query.
- `sort: array | object`: Set to sort the documents coming back from the query.
- `projection: object`: The fields to return in the query. Object of fields to either include or exclude (one of, not both), `{'a':1, 'b': 1}` or `{'a': 0, 'b': 0}`.
- `skip: number`: Set to skip N documents ahead in your query (useful for pagination).
- `hint: object`: Tell the query to use specific indexes in the query. Object of indexes to use, `{'_id':1}`.
- `comment: string`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `readPreference: string | object`: The preferred read preference.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the query.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#findone) for more information. Supported settings are:
- `allowDiskUse: boolean`: Allows disk use for blocking sort operations exceeding 100MB memory. (MongoDB 3.2 or higher)
- `allowPartialResults: boolean`: For queries against a sharded collection, allows the command (or subsequent getMore commands) to return partial results, rather than an error, if one or more queried shards are available.
- `authdb: string`: Specifies the authentication information to be used.
- `awaitData: boolean`: Specify if the cursor is a tailable-await cursor. Requires `tailable` to be true.
- `batchSize: number`: Set the batchSize for the getMoreCommand when iterating over the query results.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `checkKeys: boolean`: The serializer will check if keys are valid.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `comment: string | object`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `dbName: string`: The database name.
- `explain: boolean`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: Tell the query to use specific indexes in the query. Object of indexes to use, `{'_id':1}`.
- `ignoreUndefined: boolean`: Default: `true` - Serialize will not emit undefined fields.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `limit: number`: Sets the limit of documents returned in the query.
- `max: object`: The exclusive upper bound for a specific index.
- `maxAwaitTimeMS: number`: The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. Requires `tailable` and `awaitData` to be true.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `min: object`: The inclusive lower bound for a specific index.
- `noCursorTimeout: boolean`: The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
- `noResponse: boolean`: Admin command option.
- `projection: object`: The fields to return in the query. Object of fields to either include or exclude (one of, not both), `{'a':1, 'b': 1}` or `{'a': 0, 'b': 0}`.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: string | object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `returnKey: boolean`: If true, returns only the index keys in the resulting documents.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `showRecordId: boolean`: Determine whether to return the record identifier for each document. If true, adds a field $recordId to the returned documents.
- `singleBatch: boolean`: Default: `false` - Determines whether to close the cursor after the first batch.
- `skip: number`: Set to skip N documents ahead in your query (useful for pagination).
- `sort: array | object`: Set to sort the documents coming back from the query.
- `tailable: boolean`: Specify if the cursor is tailable.
- `timeout: boolean`: Specify if the cursor can timeout.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -271,15 +368,27 @@ _ref:
#### Properties
- `docs: object[]`: __Required__ - The array of documents to be inserted.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#insertMany) for more information. Supported settings are:
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#insertmany) for more information. Supported settings are:
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `bypassDocumentValidation: boolean`: Default: `false` - Allow driver to bypass schema validation in MongoDB 3.2 or higher
- `checkKeys: boolean`: Default: `true` - If true, will throw if bson documents start with $ or include a . in any key value.
- `forceServerObjectId: boolean`: Default: `false` - Force server to assign _id values instead of driver.
- `j: boolean`: Default: `false` - Specify a journal write concern.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `comment: string | object`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `dbName: string`: The database name.
- `explain: object`: Specifies the verbosity mode for the explain output.
- `forcesServerObjectId: boolean`: Default: `false` - Force server to assign _id values instead of driver.
- `fullResponse: boolean`: Return the full server response for the command.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `w: number | string`: The write concern.
- `wtimeout: number`: The write concern timeout.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `noResponse: boolean`: Admin command option.
- `ordered: boolean`: If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -305,14 +414,26 @@ _ref:
#### Properties
- `doc: object`: __Required__ - The document to be inserted.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#insertOne) for more information. Supported settings are:
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#insertone) for more information. Supported settings are:
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `bypassDocumentValidation: boolean`: Default: `false` - Allow driver to bypass schema validation in MongoDB 3.2 or higher
- `checkKeys: boolean`: Default: `true` - If true, will throw if bson documents start with $ or include a . in any key value.
- `forceServerObjectId: boolean`: Default: `false` - Force server to assign _id values instead of driver.
- `j: boolean`: Default: `false` - Specify a journal write concern.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `comment: string | object`: Add a [comment](https://docs.mongodb.com/manual/reference/operator/query/comment/index.html) to the query. These comments are visible in the MongoDB profile log, making them easier to interpret.
- `dbName: string`: The database name.
- `explain: object`: Specifies the verbosity mode for the explain output.
- `forcesServerObjectId: boolean`: Default: `false` - Force server to assign _id values instead of driver.
- `fullResponse: boolean`: Return the full server response for the command.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `w: number | string`: The write concern.
- `wtimeout: number`: The write concern timeout.
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `noResponse: boolean`: Admin command option.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -338,18 +459,29 @@ _ref:
#### Properties
- `filter: object`: __Required__ - The filter used to select the document to update.
- `update: object | object[]`: __Required__ - The update operations to be applied to the document.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#updateOne) for more information. Supported settings are:
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#updatemany) for more information. Supported settings are:
- `arrayFilters: string[]`: Array filters for the [`$[<identifier>]`](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/) array update operator.
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `bypassDocumentValidation: boolean`: Default: `false` - Allow driver to bypass schema validation in MongoDB 3.2 or higher.
- `checkKeys: boolean`: Default: `false` - If true, will throw if bson documents start with $ or include a . in any key value.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `forceServerObjectId: boolean`: Force server to assign _id values instead of driver.
- `hint: object`: An optional hint for query optimization.
- `comment: string | object`: A user-provided comment to attach to this command.
- `dbName: string`: The database name.
- `explain: object`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: An optional hint for query optimization.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `j: boolean`: Specify a journal write concern.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `noResponse: boolean`: Admin command option.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFuntions: boolean`: Default: `false` - Serialize the javascript functions.
- `upsert: boolean`: Default: `false` - Insert document if no match is found.
- `w: number | string`: The write concern.
- `wtimeout: number`: The write concern timeout.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples
@ -390,19 +522,29 @@ _ref:
#### Properties
- `filter: object`: __Required__ - The filter used to select the document to update.
- `update: object | object[]`: __Required__ - The update operations to be applied to the document.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#updateOne) for more information. Supported settings are:
- `arrayFilters: string[]`: _Array_ - Array filters for the [`$[<identifier>]`](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/) array update operator.
- `options: object`: Optional settings. See the [driver docs](https://mongodb.github.io/node-mongodb-native/4.0/classes/collection.html#updateone) for more information. Supported settings are:
- `arrayFilters: object[]`: _Array_ - Array filters for the [`$[<identifier>]`](https://docs.mongodb.com/manual/reference/operator/update/positional-filtered/) array update operator.
- `authdb: string`: Specifies the authentication information to be used.
- `bsonRegExp: boolean`: Return the BSON regular expressions as BSONRegExp instances.
- `bypassDocumentValidation: boolean`: Default: `false` - Allow driver to bypass schema validation in MongoDB 3.2 or higher.
- `checkKeys: boolean`: Default: `false` - If true, will throw if bson documents start with $ or include a . in any key value.
- `collation: object`: Specify collation (MongoDB 3.4 or higher) settings for update operation.
- `forceServerObjectId: boolean`: Force server to assign _id values instead of driver.
- `hint: object`: An optional hint for query optimization.
- `comment: string | object`: A user-provided comment to attach to this command.
- `dbName: string`: The database name.
- `explain: object`: Specifies the verbosity mode for the explain output.
- `fullResponse: boolean`: Return the full server response for the command.
- `hint: string | object`: An optional hint for query optimization.
- `ignoreUndefined: boolean`: Default: `false` - Specify if the BSON serializer should ignore undefined fields.
- `j: boolean`: Specify a journal write concern.
- `let: object`: Map of parameter names and values that can be accessed using `$$var` (requires MongoDB 5.0).
- `maxTimeMS: number`: Number of milliseconds to wait before aborting the command.
- `noResponse: boolean`: Admin command option.
- `readConcern: object`: Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported).
- `readPreference: object`: The preferred read preference.
- `retryWrites: boolean`: Should retry failed writes.
- `serializeFunctions: boolean`: Default: `false` - Serialize the javascript functions.
- `upsert: boolean`: Default: `false` - Insert document if no match is found.
- `w: integer | string`: The write concern
- `wtimeout: integer`: The write concern timeout.
- `willRetryWrites: boolean`: Option whether to retry writes.
- `writeConcern: object`: An object that expresses the write concern.
#### Examples

View File

@ -27,18 +27,46 @@ class Actions {
this.actions = actions;
}
async callAsyncAction({ action, arrayIndices, block, event, index, responses }) {
try {
const response = await this.callAction({
action,
arrayIndices,
block,
event,
index,
responses,
});
responses[action.id] = response;
} catch (error) {
responses[action.id] = error;
console.error(error);
}
}
async callActionLoop({ actions, arrayIndices, block, event, responses }) {
for (const [index, action] of actions.entries()) {
try {
const response = await this.callAction({
action,
arrayIndices,
block,
event,
index,
responses,
});
responses[action.id] = response;
if (action.async === true) {
this.callAsyncAction({
action,
arrayIndices,
block,
event,
index,
responses,
});
} else {
const response = await this.callAction({
action,
arrayIndices,
block,
event,
index,
responses,
});
responses[action.id] = response;
}
} catch (error) {
responses[action.id] = error;
throw {

View File

@ -15,7 +15,9 @@
*/
import { type, serializer } from '@lowdefy/helpers';
async function JsAction({ context, params }) {
import actionFns from './index.js';
async function JsAction({ context, event, params, arrayIndices, blockId }) {
if (!type.isString(params.name)) {
throw new Error(`JsAction requires a string for 'params.name'.`);
}
@ -25,15 +27,29 @@ async function JsAction({ context, params }) {
if (!type.isFunction(context.lowdefy.imports.jsActions[params.name])) {
throw new Error(`JsAction ${params.name} is not a function.`);
}
const actions = {};
Object.keys(actionFns).forEach((name) => {
actions[name] = (actionParams) =>
actionFns[name]({
arrayIndices,
blockId,
context,
event,
params: actionParams,
});
});
return context.lowdefy.imports.jsActions[params.name](
{
...serializer.copy({
user: context.lowdefy.user,
global: context.lowdefy.lowdefyGlobal,
input: context.lowdefy.inputs[context.id],
state: context.state,
urlQuery: context.lowdefy.urlQuery,
input: context.lowdefy.inputs[context.id],
user: context.lowdefy.user,
}),
actions,
contextId: context.id,
pageId: context.pageId,
requests: { ...context.requests },

View File

@ -21,15 +21,26 @@ import actions from '../../src/actions/index.js';
jest.mock('../../src/actions/index.js', () => ({
ActionSync: jest.fn(({ params }) => params),
ActionAsync: jest.fn(({ params }) => Promise.resolve(params)),
ActionAsync: jest.fn(async ({ params }) => {
await timeout(params.ms || 1);
return params;
}),
ActionError: jest.fn(() => {
throw new Error('Test error');
}),
CatchActionError: jest.fn(() => {
throw new Error('Test catch error');
}),
ActionAsyncError: jest.fn(async ({ params }) => {
await timeout(params.ms || 1);
throw new Error('Test error');
}),
}));
const timeout = (ms) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
const pageId = 'one';
const RealDate = Date;
@ -1097,3 +1108,215 @@ test('Call catchActions when actions throws error and catchActions throws error'
});
expect(actions.ActionAsync.mock.calls.length).toBe(1);
});
test('call 2 actions, first with async: true', async () => {
const rootBlock = {
blockId: 'root',
meta: {
category: 'context',
},
};
const context = await testContext({
lowdefy,
rootBlock,
});
const Actions = context.Actions;
const res = await Actions.callActions({
actions: [
{ id: 'test1', type: 'ActionAsync', async: true, params: { ms: 100 } },
{ id: 'test2', type: 'ActionSync', params: 'params2' },
],
arrayIndices,
block: { blockId: 'blockId' },
catchActions: [],
event: {},
eventName,
});
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test2: {
type: 'ActionSync',
index: 1,
response: 'params2',
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
await timeout(110);
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test1: {
type: 'ActionAsync',
index: 0,
response: { ms: 100 },
},
test2: {
type: 'ActionSync',
index: 1,
response: 'params2',
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
});
test('call async: true with error', async () => {
const rootBlock = {
blockId: 'root',
meta: {
category: 'context',
},
};
const context = await testContext({
lowdefy,
rootBlock,
});
const Actions = context.Actions;
const res = await Actions.callActions({
actions: [
{ id: 'test1', type: 'ActionAsyncError', async: true, params: { ms: 100 } },
{ id: 'test2', type: 'ActionSync', params: 'params2' },
],
arrayIndices,
block: { blockId: 'blockId' },
catchActions: [],
event: {},
eventName,
});
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test2: {
type: 'ActionSync',
response: 'params2',
index: 1,
},
},
endTimestamp: { date: 0 },
startTimestamp: { date: 0 },
success: true,
});
await timeout(110);
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test2: {
type: 'ActionSync',
response: 'params2',
index: 1,
},
test1: {
type: 'ActionAsyncError',
error: new Error('Test error'),
index: 0,
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
});
test('call 2 actions, first with async: false', async () => {
const rootBlock = {
blockId: 'root',
meta: {
category: 'context',
},
};
const context = await testContext({
lowdefy,
rootBlock,
});
const Actions = context.Actions;
const res = await Actions.callActions({
actions: [
{ id: 'test1', type: 'ActionAsync', async: false, params: { ms: 100 } },
{ id: 'test2', type: 'ActionSync', params: 'params2' },
],
arrayIndices,
block: { blockId: 'blockId' },
catchActions: [],
event: {},
eventName,
});
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test1: {
type: 'ActionAsync',
index: 0,
response: { ms: 100 },
},
test2: {
type: 'ActionSync',
index: 1,
response: 'params2',
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
});
test('call 2 actions, first with async: null', async () => {
const rootBlock = {
blockId: 'root',
meta: {
category: 'context',
},
};
const context = await testContext({
lowdefy,
rootBlock,
});
const Actions = context.Actions;
const res = await Actions.callActions({
actions: [
{ id: 'test1', type: 'ActionAsync', async: null, params: { ms: 100 } },
{ id: 'test2', type: 'ActionSync', params: 'params2' },
],
arrayIndices,
block: { blockId: 'blockId' },
catchActions: [],
event: {},
eventName,
});
expect(res).toEqual({
blockId: 'blockId',
event: {},
eventName: 'eventName',
responses: {
test1: {
type: 'ActionAsync',
index: 0,
response: { ms: 100 },
},
test2: {
type: 'ActionSync',
index: 1,
response: 'params2',
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
});

View File

@ -15,6 +15,7 @@
*/
import testContext from '../testContext';
import actionFns from '../../src/actions/index.js';
const pageId = 'one';
const lowdefy = { pageId };
@ -24,7 +25,7 @@ const mockDate = jest.fn(() => ({ date: 0 }));
mockDate.now = jest.fn(() => 0);
// Comment out to use console.log
console.log = () => {};
// console.log = () => {};
beforeAll(() => {
global.Date = mockDate;
@ -201,35 +202,57 @@ test('JsAction with args, synchronous fn', async () => {
const { button } = context.RootBlocks.map;
const res = await button.triggerEvent({ name: 'onClick' });
expect(res).toEqual({
blockId: 'button',
event: undefined,
eventName: 'onClick',
responses: {
a: {
type: 'JsAction',
index: 0,
response: [
{
contextId: 'test',
input: {},
pageId: 'root',
requests: {},
state: {},
urlQuery: {},
},
1,
'2',
{
date: 0,
},
],
expect(res).toMatchInlineSnapshot(`
Object {
"blockId": "button",
"endTimestamp": Object {
"date": 0,
},
},
success: true,
startTimestamp: { date: 0 },
endTimestamp: { date: 0 },
});
"event": undefined,
"eventName": "onClick",
"responses": Object {
"a": Object {
"index": 0,
"response": Array [
Object {
"actions": Object {
"CallMethod": [Function],
"JsAction": [Function],
"Link": [Function],
"Login": [Function],
"Logout": [Function],
"Message": [Function],
"Request": [Function],
"Reset": [Function],
"ScrollTo": [Function],
"SetGlobal": [Function],
"SetState": [Function],
"Throw": [Function],
"Validate": [Function],
"Wait": [Function],
},
"contextId": "test",
"input": Object {},
"pageId": "root",
"requests": Object {},
"state": Object {},
"urlQuery": Object {},
},
1,
"2",
Object {
"date": 0,
},
],
"type": "JsAction",
},
},
"startTimestamp": Object {
"date": 0,
},
"success": true,
}
`);
expect(mockFn).toHaveBeenCalledTimes(1);
});
@ -445,3 +468,54 @@ test('JsAction args not a function', async () => {
endTimestamp: { date: 0 },
});
});
test('JsAction can use Lowdefy actions', async () => {
const rootBlock = {
blockId: 'root',
meta: {
category: 'context',
},
areas: {
content: {
blocks: [
{
blockId: 'button',
type: 'Button',
meta: {
category: 'display',
valueType: 'string',
},
events: {
onClick: [
{
id: 'a',
type: 'JsAction',
params: {
name: 'test_fn',
},
},
],
},
},
],
},
},
};
const context = await testContext({
lowdefy,
rootBlock,
});
const fn = async ({ actions }) => {
actions.SetState({ answer: 42 });
return actions;
};
const mockFn = jest.fn().mockImplementation(fn);
context.lowdefy.imports.jsActions.test_fn = mockFn;
const { button } = context.RootBlocks.map;
const res = await button.triggerEvent({ name: 'onClick' });
expect(context.state).toEqual({ answer: 42 });
expect(Object.keys(res.responses.a.response)).toEqual(Object.keys(actionFns));
});

View File

@ -59,7 +59,7 @@
"knex": "0.95.6",
"mingo": "4.1.2",
"moment": "2.29.1",
"mongodb": "3.6.9",
"mongodb": "4.1.0",
"mssql": "7.1.0",
"mysql": "2.18.1",
"openid-client": "4.7.4",

View File

@ -18,11 +18,8 @@ import { MongoClient } from 'mongodb';
async function getCollection({ connection }) {
let client;
const { databaseUri, databaseName, collection } = connection;
client = new MongoClient(databaseUri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const { collection, databaseUri, databaseName, options } = connection;
client = new MongoClient(databaseUri, options);
await client.connect();
try {
const db = client.db(databaseName);

View File

@ -3306,7 +3306,7 @@ __metadata:
knex: 0.95.6
mingo: 4.1.2
moment: 2.29.1
mongodb: 3.6.9
mongodb: 4.1.0
mssql: 7.1.0
mysql: 2.18.1
openid-client: 4.7.4