环回更新模型扩展自用户模型错误

Loopback Update model extend from User Model Error

我创建了一个以 User 作为其基础模型的 Artist 模型。我试图通过 Loopback 资源管理器更新艺术家模型,但出现错误:

"message": "ValidationError: The Artist instance is not valid. Details: password can't be blank (value: undefined); email can't be blank (value: undefined)."

我已经注册了一个示例信息,我在 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": {}
}

我在这里遗漏了什么吗?

因为您的实体继承自 User 模型,它需要具有“密码”和“”使用 POSTPUT 方法时设置的 email' 属性(因此 whole 对象是 created/updated) - 因为它们用于让用户登录。

如果您只想更新您的艺术家而不传递整个数据,请使用 PATCH。 (然后'密码'和'电子邮件'将不再是强制性的)。

如果您不需要使用 Loopback 的登录系统,请不要从 User 模型继承您的实体。 (或者你这样做还有其他原因吗?)