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

Use loopback framework to add default values #1

Open
pulkitsinghal opened this issue Mar 25, 2016 · 0 comments
Open

Use loopback framework to add default values #1

pulkitsinghal opened this issue Mar 25, 2016 · 0 comments
Assignees

Comments

@pulkitsinghal
Copy link

While user data such as:

        {
            name:'Aquid Shahwar',
            username: 'shahwarcoder',
            email: '[email protected]', 
            password: 'aquid123',
            createdAt: new Date(),
        }

is perfectly valid. If you want to take your familiarity with the loopback framework further, then take the next step by defining your user's model to perform an automatic value injection for the createdAt field.

References:

  1. Look for defaultFn
  2. Github has samples too, search code with keywords: defaultfn language:json

Also some tangential concepts and fun reads:

A mixin to automatically generate createdAt and updatedAt Date attributes for loopback Models:
https://github.com/clarkbw/loopback-ds-timestamp-mixin

Sample / example:
https://github.com/strongloop/loopback-example-mixins

Use Mixins for everything!
strongloop/loopback#1578

@aquid aquid self-assigned this Mar 25, 2016
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