-
Notifications
You must be signed in to change notification settings - Fork 141
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
How to add fields to User model? #119
Comments
I don't know what you mean by not change the User model. That's definitely the easiest way to do it: // api/models/User.js
var _ = require('lodash');
var _super = require('sails-permissions/api/models/User');
_.merge(exports, _super);
_.merge(exports, {
// Extend with custom logic here by adding additional fields, methods, etc.
attributes: {
name: {
type: 'string'
},
some_other_data: {
type: 'string'
}
}
}); |
+1 for @DaAwesomeP solution |
@DaAwesomeP Absolutely! This can be the way to go.
@alerdenisov, If you really don't want to add profile data in User table, you can create a one-to-one mapping between your User model and Profile model. Check this link to see how to create one-to-one associations. PS: For creating a separate model as well, you will have to create a one-to-one mapping field in the User and Profile Models. For adding the field, you will have to extend the User model as DaAwesomeP suggested. You're out of luck there IMO! |
@aman-gautam while you have a very good point, how do you set the profile that the autogenerated admin uses? |
I need to profile and extra data on User, but doesn't want to change User model in module. What i need to do?
The text was updated successfully, but these errors were encountered: