Created
May 10, 2011 17:20
-
-
Save samyakbhuta/964941 to your computer and use it in GitHub Desktop.
_id is nor set neither returned in .save function of Model
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 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