auths
objectA JavaScript object representing the document to be inserted
The collection you'd like to insert data into
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params, auths) => {
}
const MongoClient = require('mongodb').MongoClient
const {
database,
hostname,
username,
password,
} = auths.mongodb
const url = `mongodb+srv://${username}:${password}@${hostname}/test?retryWrites=true&w=majority`
const client = await MongoClient.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true
})
this.data = params.document
const db = client.db(database)
// Enter your target collection as a parameter to this step
this.res = await db.collection(params.collection).insertOne(params.document)
await client.close()