Skip to content

Instantly share code, notes, and snippets.

@ethanwillis
Created May 5, 2017 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanwillis/5d378f62ed118ec8975a049e4359f822 to your computer and use it in GitHub Desktop.
Save ethanwillis/5d378f62ed118ec8975a049e4359f822 to your computer and use it in GitHub Desktop.
Mongo Client Example
var MongoClient = require('mongodb').MongoClient;
var mongo_url = "mongodb://localhost:27017/mydbname"
MongoClient.connect(settings.application_settings.mongo_url, function(err, db_client) {
var mongo_collection = db_client.collection("a_collection_name");
// Insert empty object { } or whatever you want
mongo_collection.insert({ }, function(err, result) {
// handle err and result
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment