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

问题描述 投票:3回答:2

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

  • 用户名
  • 密码
  • 领域
  • emailVerified

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

javascript node.js model loopbackjs
2个回答
2
投票

如果您根据自己的问题添加了代码以获得更好的答案,那就更好了,但是您可以查看this网站,其中讨论了自定义built-in user model以及this。我希望这回答了你的问题。


1
投票

创建一个新模型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": []
}

将其添加到model-config.json

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

希望这对你有用

© www.soinside.com 2019 - 2024. All rights reserved.