Reputation: 671
I have created an Artist model with User as its based model. I was trying to update the artist model through the Loopback explorer but i have an error:
"message": "ValidationError: The
Artist
instance is not valid. Details:password
can't be blank (value: undefined);
I have already registered a sample info and i have it in my artist db in MongoDB. i am not sure why i need to put something in the email and password field when i was only trying to update an existing data?
here is my artist JSON:
{
"name": "Artist",
"base": "User",
"idInjection": false,
"options": {
"validateUpsert": true,
"strictObjectIDCoercion": true
},
"properties": {
"firstName": {
"type": "string"
},
"middleName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"telephoneNumber": {
"type": "string"
},
"country": {
"type": "string"
},
"city": {
"type": "string"
},
"genre": {
"type": "string"
},
"description": {
"type": "string"
},
"pricing": {
"type": "string"
},
"profilePicture": {
"type": "string"
}
},
"validations": [],
"acls": [
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW",
"property": "create"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW",
"property": [
"updateAttributes",
"deleteById"
]
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"methods": {}
}
Am i missing something here?
Upvotes: 1
Views: 419
Reputation: 2665
Because your entity is inherited from a User model, it needs to have the 'password' and 'email' attributes set when using POST or PUT methods (so the whole object is created/updated) - as they are used to log the user in.
If you simply want to update your Artist whithout passing the whole datas, use PATCH. (Then 'password' and 'email' won't be mandatory anymore).
If you don't need to use the Loopback's login system, do not inherit your entity from the User model. (Or is there another reason for you to do so?)
Upvotes: 2