Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It would be better if there's an option for naming fields such as 'deletedAt' #92

Open
chan-dev opened this issue Sep 19, 2020 · 3 comments

Comments

@chan-dev
Copy link

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();
});
@arthur-alvesaf
Copy link

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.

@chan-dev
Copy link
Author

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

@mohamedashrafothman
Copy link

I agree with this as well, I ended up renaming all snake_case fields to match up with the camelCase convention this plugin use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants