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

Underscored createdAt and updatedAt #5846

Closed
awm33 opened this issue Dec 6, 2014 · 5 comments
Closed

Underscored createdAt and updatedAt #5846

awm33 opened this issue Dec 6, 2014 · 5 comments

Comments

@awm33
Copy link

awm33 commented Dec 6, 2014

Is there a way to change the default createdAt and updatedAt to created_at and updated_at while keeping the automatic behavior for updated_at? created_at could just use a defaultTo

I'm trying to use waterline with an existing database that uses underscores

@particlebanana
Copy link
Contributor

Not currently but you could tap into the beforeCreate and beforeUpdate lifecycle callbacks to do the same thing the auto ones do.

@elad
Copy link

elad commented Feb 11, 2015

@particlebanana I'd like to do this too, would you be receptive to such a change?

If yes, I have two ideas:

  • Repurpose autoCreatedAt and autoUpdatedAt so they either accept a boolean (current functionality) or a string to be used as the field name. As in, autoCreatedAt: 'created_at'.
  • Introduce two new options to specify field names.

Thoughts? (I prefer the first)

@awm33
Copy link
Author

awm33 commented Feb 11, 2015

@elad I like the first one as well, just modifying autoCreatedAt and autoUpdatedAt. I'd be opening to adding it / contributing it. I'm just not sure how @particlebanana / the community would want it work. I've actually never contributed to a large open source project before

@Esya
Copy link

Esya commented Apr 11, 2015

I just started implementing this change, pull-request incoming soon.

@devinivy
Copy link

See @Esya's PR balderdashy/waterline-schema#23

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants