mongoose-delete
mongoose-delete copied to clipboard
It would be better if there's an option for naming fields such as 'deletedAt'
I'm using mongoose timestamps in my schema and they're in the format like this:
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at',
}
I would like to rename deletedAt field to deleted_at. Is there a way to rename the field.
I tried using middleware like this.
Using Bookmark.deleteById or Bookmark.restore invokes updateMany relative to my mongo version, so i have to use updateMany middleware.
The code below doesn't return the current doc updated
BookmarkSchema.post('updateMany', (doc, next) => {
// This doesn't return the current document but rahter metadata of how many documents are updated
console.log({ doc });
next();
});
I agree.. I'm trying to do this exact thing with my mongo objects and I haven't found a way to update the variable names created by this package.
i ended up renaming my fields to follow the naming convention in this package. But it would still be better to allow renaming option here
I agree with this as well, I ended up renaming all snake_case fields to match up with the camelCase convention this plugin use.