Skip to content

Instantly share code, notes, and snippets.

@samyakbhuta
Created May 10, 2011 17:20
Show Gist options
  • Save samyakbhuta/964941 to your computer and use it in GitHub Desktop.
Save samyakbhuta/964941 to your computer and use it in GitHub Desktop.
_id is nor set neither returned in .save function of Model
var mongoose = require('mongoose');
var myUserModel = require("./players").playerModel;
var util = require("util");
exports.insertUser = function (pn,di,ti){
var aUserInstance = new myUserModel();
aUserInstance.pn = pn;
aUserInstance.di = di;
aUserInstance.ti = ti;
aUserInstance.ls = +new Date();
console.log(aUserInstance);
var aP = new Object();
aUserInstance.save(function(err){
if (err==null){
console.log("Saved a User document");
setTimeout(function() {
console.log("aUserInstance :>>> "+ util.inspect(aUserInstance, showHidden=true, depth=5));
}, 5000);
}else {
console.log("Couldn't save " + err);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment