Why is loopback throwing the error: The `ModelDefinition` instance is not valid
Why is loopback throwing the error: The `ModelDefinition` instance is not valid
我正在 Strongloop 兜风。我只是在尝试 "Getting Started" 教程,基本功能通常 want/need.
我正在使用 Windows 和 PostgresSQL,所以我创建了一个新数据源并编辑了 model-config.json
以将内置模型数据源更改为这个新数据源,我们称之为 lbdev
.
之后,我关注了关于 creating the tables for the built-in models 的文档部分。 tables 已创建(在 PgAdmin 中一切看起来都很好)。我 运行 浏览器和唯一的 public API(用户)在那里,到目前为止一切顺利。
接下来,我尝试使用 Arc 从 lbdev
模式(table 为空)中发现模型,但是对于其中的每个 table 我都收到以下错误:
Oops! Something is wrong
The ModelDefinition
instance is not valid.
Details: name
is not unique (value: "User").
Name: ValidationError
Message: The ModelDefinition
instance is not valid. Details: name
is not unique (value: "User").
Details: {"context":"ModelDefinition","codes":{"name":["uniqueness"]},"messages":{"name":["is not unique"]}}
Request: /workspace/api/DataSourceDefinitions/server.lbdev/createModel
status: 422
好像已经完成了,但是Arc中的Models树是空的。有人可以阐明这里发生的事情吗?
注意: another post 有类似的问题,但提供的信息很少,所以我创建了一个新的。
正在将我的评论复制到答案中...
我不确定您为什么要尝试在该架构上发现模型...是否已经存在其他表?如果是这样,那么您只想拉入那些,而不是 从内置 LoopBack 模型自动创建的表。如果您尝试 "discover" 您刚刚从中生成表格的模型,那么您自然会拥有重复的模型(它们是内置的,它们已经存在)。
如果您想管理、扩展、更改任何内置模型,那么您需要创建一个新模型并使用任何内置模型作为基础:
// common/models/visitor.json
{
"name": "Visitor",
"base": "User",
// ... other options
"properties": {
// ... additional properties to those already on User
},
"acls": [
// ... additional ACLs to those on User... careful, these might overwrite built-in restrictions!
],
// ... other overwrites/additions
}
我正在 Strongloop 兜风。我只是在尝试 "Getting Started" 教程,基本功能通常 want/need.
我正在使用 Windows 和 PostgresSQL,所以我创建了一个新数据源并编辑了 model-config.json
以将内置模型数据源更改为这个新数据源,我们称之为 lbdev
.
之后,我关注了关于 creating the tables for the built-in models 的文档部分。 tables 已创建(在 PgAdmin 中一切看起来都很好)。我 运行 浏览器和唯一的 public API(用户)在那里,到目前为止一切顺利。
接下来,我尝试使用 Arc 从 lbdev
模式(table 为空)中发现模型,但是对于其中的每个 table 我都收到以下错误:
Oops! Something is wrong The
ModelDefinition
instance is not valid.Details:
name
is not unique (value: "User").Name: ValidationError
Message: The
ModelDefinition
instance is not valid. Details:name
is not unique (value: "User").Details: {"context":"ModelDefinition","codes":{"name":["uniqueness"]},"messages":{"name":["is not unique"]}}
Request: /workspace/api/DataSourceDefinitions/server.lbdev/createModel
status: 422
好像已经完成了,但是Arc中的Models树是空的。有人可以阐明这里发生的事情吗?
注意: another post 有类似的问题,但提供的信息很少,所以我创建了一个新的。
正在将我的评论复制到答案中...
我不确定您为什么要尝试在该架构上发现模型...是否已经存在其他表?如果是这样,那么您只想拉入那些,而不是 从内置 LoopBack 模型自动创建的表。如果您尝试 "discover" 您刚刚从中生成表格的模型,那么您自然会拥有重复的模型(它们是内置的,它们已经存在)。
如果您想管理、扩展、更改任何内置模型,那么您需要创建一个新模型并使用任何内置模型作为基础:
// common/models/visitor.json
{
"name": "Visitor",
"base": "User",
// ... other options
"properties": {
// ... additional properties to those already on User
},
"acls": [
// ... additional ACLs to those on User... careful, these might overwrite built-in restrictions!
],
// ... other overwrites/additions
}