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

add custom functions to model #60

Open
techo207 opened this issue Oct 5, 2019 · 1 comment
Open

add custom functions to model #60

techo207 opened this issue Oct 5, 2019 · 1 comment

Comments

@techo207
Copy link

techo207 commented Oct 5, 2019

sometimes is necessary add custom functions in model, for example a function "is Password" for check plain password with encrypted saved password

@4strid
Copy link
Owner

4strid commented Oct 11, 2019

I've always handled this at a layer of abstraction one level above the database models themselves. Heck you can even attach them to the model itself, since it's just a plain object. Here's how I do it in one of my projects:

https://github.com/4strid/diet-vhost/blob/master/app_modules/ctrl-panel/lib/models/user.js

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

2 participants