mongoose get id after save
n.save(function(err,room){
var newRoomId = room._id;
});
mongoose get id after save
n.save(function(err,room){
var newRoomId = room._id;
});
mongoose save return id
//if you are sending an id field in req.body then mongoose will return e null _id
//to solve this just delete the _id field before running the save method
if(req.body._id === null) {
delete req.body._id;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us