Skip to content

Instantly share code, notes, and snippets.

@oeeckhoutte
Created January 17, 2013 13:38
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 oeeckhoutte/4555957 to your computer and use it in GitHub Desktop.
Save oeeckhoutte/4555957 to your computer and use it in GitHub Desktop.
[Node] Mongoose | MongoDB methods
//FIND
dbSchemasName.ModelName.find({ 'key1': value1, 'key2': value2 }, function (err, resultFromDB) {
if(resultFromDB.length === 0) {
var model = {
key1: value1,
key2: value2
};
}
});
//CREATE
dbSchemasName.ModelName.create(model, function (err) {
d(err);
d("model created");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment