如何在 Loopback 中将模型 ID 设置为字符串?
How to set Model id to a string in Loopback?
我有一个字符串可以用来唯一标识一个模型实例,例如,email - john@doe.com,它只能分配给数据库中的一个实例,这意味着它不会被骗了。
现在,如何使这个字符串从一个变量中自动分配给创建时自动分配给新创建的实例?
我刚刚在文档中找到它:
In database terms, ID properties are primary key column(s) are. Such properties are defined with the 'id' attribute set to true or a number as the position for a composite key.
{
"myId": {
"type": "string",
"id": true
}
}
我有一个字符串可以用来唯一标识一个模型实例,例如,email - john@doe.com,它只能分配给数据库中的一个实例,这意味着它不会被骗了。
现在,如何使这个字符串从一个变量中自动分配给创建时自动分配给新创建的实例?
我刚刚在文档中找到它:
In database terms, ID properties are primary key column(s) are. Such properties are defined with the 'id' attribute set to true or a number as the position for a composite key.
{
"myId": {
"type": "string",
"id": true
}
}