Answers for "mongoose get id after save"

0

mongoose get id after save

n.save(function(err,room){
  var newRoomId = room._id;
  });
Posted by: Guest on December-20-2020
0

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;
}
Posted by: Guest on December-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language