Skip to main content

mongodb@2.0.2

Functions

connect(state)
disconnect(state)
execute(operations)
findDocuments(params)
insertDocuments(params)
updateDocument(params)

The following functions are exported from the common adaptor:

alterState()
dataPath()
dataValue()
each()
field()
fields()
fn()
lastReferenceValue()
merge()
sourceValue()

connect

connect(state) ⇒ State

Connects to a mongoDb instance

ParamTypeDescription
stateStateRuntime state.

Example

connect(state)

disconnect

disconnect(state) ⇒ State

Removes connection from the state.

ParamType
stateState

Example

disconnect(state)

execute

execute(operations) ⇒ Operation

Execute a sequence of operations. Wraps @openfn/language-common/execute, and prepends initial state for http.

ParamTypeDescription
operationsOperationsOperations to be performed.

Example

execute(
insertDocuments(params),
findDocuments(params)
)(state)

findDocuments

findDocuments(params) ⇒ State

Find documents in a mongoDb collection

ParamTypeDescription
paramsobjectConfiguration for mongo

Example

findDocuments({
database: 'str',
collection: 'cases',
query: {a:3}
});

insertDocuments

insertDocuments(params) ⇒ State

Inserts documents into a mongoDb collection

ParamTypeDescription
paramsobjectConfiguration for mongo

Example

insertDocuments({
database: 'str',
collection: 'kids',
documents: [1,2,3]
});

updateDocument

updateDocument(params) ⇒ State

Updates document (optionally upserting) into a mongoDb collection

ParamTypeDescription
paramsobjectConfiguration for mongo

Example

updateDocuments({
database: 'str',
collection: 'animals',
filter: { type: 'fuzzy' },
changes: { kind: 'soft' },
options: { upsert: true }
});