could i update “_id” primary key on update hook:
// Hook
before: {
update: function (doc) {
doc.$set._id = '005'; // before _id = 001
return doc;
}
},
How to?
could i update “_id” primary key on update hook:
// Hook
before: {
update: function (doc) {
doc.$set._id = '005'; // before _id = 001
return doc;
}
},
How to?
You cannot update the _id
value. That is a MongoDB restriction. The only way to do what you want is to insert a new document and delete the old one.
Thanks for replying …