Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 353 Bytes

section28.2.md

File metadata and controls

14 lines (13 loc) · 353 Bytes

Section 28.2: Simple connect, using promises

const MongoDB = require('mongodb');
MongoDB.connect('mongodb://localhost:27017/databaseName')
  .then(function(database) {
    const collection = database.collection('collectionName');
    return collection.insert({key: 'value'});
  })
  .then(function(result) {
    console.log(result);
  }
);