我已创建了用户作为其基于模型的艺术家模型。我试图更新通过环回探险家,艺术家模型,但我有一个错误:
“消息”:“ValidationError:该
Artist
实例是无效的详细说明:password
不能为空(值:未定义);
我已经注册了一个样本的信息,我有它在我的MongoDB数据库艺术家。我不知道为什么我需要把东西时,我只是想更新现有数据的电子邮件和密码字段?
这里是我的艺术家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": {}
}
我失去了一些东西?
因为你的实体从用户模型继承,它需要有“密码”和“电子邮件”属性设置使用POST或PUT方法(所以创造了整个对象/更新)时 - 因为它们是用来记录用户在。
如果您只是想,而没有经过整个数据集更新您的艺术家,使用补丁。 (然后“密码”和“电子邮件”不会是强制性的了)。
如果您不需要使用回送的登录系统,不继承User模型的实体。 (或者是有其他原因你这样做?)