HelloThe documentation and googled answers did not work for me. How can I add simple createdAt (created from Date.now() on creation, I got this), and updatedAt fields to my Schema?I tried having a myModel.Schema.pre('findOneAndUpdate') hook to update the myInstance.updatedAt = Date.now() whenever I update it via API endpoint, but that doesn't seem to work.pre('save') hooks work though. Is it acceptable to dofindOne().then((myInstance)=> { myInstance.updatedAt = Date.now(); return myInstance.save() just like in , say, Parse?edit: nvm I'm dumb, it says clearly, model pre hook is not supported for findOneAndUpdate in documents :)
Submitted May 03, 2017 at 05:52PM by guitarcodebakeseduce
No comments:
Post a Comment