Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Last active January 11, 2019 12:17
Show Gist options
  • Save pablocattaneo/503a91249699cd1b7238642a816121da to your computer and use it in GitHub Desktop.
Save pablocattaneo/503a91249699cd1b7238642a816121da to your computer and use it in GitHub Desktop.
Source: http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#insertOne
// getDb is a fiction function that connect database and return a client
db.getDb()
.db()
.collection('collectionName')
.insertOne(documentToInsert).then(()=> {
// Code after mongodb stored the document in the collection
}).catch(err => {
// error managing
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment