扩展内置用户模型以支持环回中的更多属性和行为

Extend built-in User model to support more properties and behaviors in loopback

我想要一个模型来表示我的 loopback 应用程序中的配置文件。但是,在 loopback 中找到的内置 User 模型只有以下属性

扩展 built-in User model 以插入更多属性(例如 phone numberprofile picturelikes 的最佳方法是什么?

根据您的问题添加代码以获得更好的答案会更好,但您可以查看 this site which talks about customizing the built-in user model and also this。我希望这回答了你的问题。

创建一个新模型common/models/user。json

{
  "name": "user",
  "base": "User",
  "idInjection": true,
  "properties": {
      "firstName"{
         "type":"string",
         "required":true
       }
   }
  "restrictResetPasswordTokenScope": true,
  "emailVerificationRequired": true,
  "validations": [],
  "relations": {},
  "acls": [
    {
      "principalType": "ROLE",
      "principalId": "$everyone",
      "accessType": "READ",
      "permission": "ALLOW"
    }
  ],
  "methods": []
}

将此添加到模型中-config.json

  "user":
    "dataSource": "yourDataSource"
  }

希望这对你有用