Created
June 25, 2011 18:52
-
-
Save guiomie/1046775 to your computer and use it in GitHub Desktop.
Function parameters not passed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var writeToCollection = function(collectionName, jsonObject){ | |
try{ | |
//the db name is hardcoded, | |
var collection = new mongo.Collection(db, collectionName); | |
collection.insert(jsonObject, {safe:true}, function(err, objects) { | |
if(err != null){ | |
sys.log("Could not write JSON in collection ->" + err); | |
} | |
if (err && err.message.indexOf('E11000 ') !== -1) { | |
// this _id was already inserted in the database | |
sys.log("Id is already in DB ->" + err); | |
} | |
if(err === null){ | |
sys.log("JSON added to database"); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment