Could i update "_id" primary key on update hook of autoform?


#1

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?


#2

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.


#3

Thanks for replying …