-
Notifications
You must be signed in to change notification settings - Fork 50
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
Adding field hooks to existing model #63
Comments
@zuhair-naqvi It's not so easy. If it's an existing model you need to assign the hooks to |
@tothandras that worked, thanks heaps! The next thing I'm trying to figure out is how to return the formatted date which is a string as a virtual property something like |
@zuhair-naqvi Virtual fields are not supported currently (#25), but you can try to modify the |
I think #64 will address this use case too! |
@zuhair-naqvi have you managed to fix this issue? |
The field hook example shows creation of a new model using mongoose.schema, how do I add field hooks to existing models?
Eg. If I want to format the a timestamp into 'x hours ago' string. Please see pseudo-code for what I'm trying to achieve:
I'm sure there's a way to do this, just struggling to get my head around hooks docs!
Thanks in advance :)
The text was updated successfully, but these errors were encountered: