I am taking Strongloop for a spin. I am just trying the "Getting Started" tutorials, and the basic functionality one would typically want/need.
I am using Windows and PostgresSQL, so I created a new datasource and edited the model-config.json
to change the built-in models datasource to this new one, lets call it lbdev
.
After that I followed the docs section about creating the tables for the built-in models. The tables were created (everything looks fine in PgAdmin). I ran the explorer and the only public API (Users) is there, so far so good.
Next, using Arc I am trying to discover the models from the lbdev
schema (with empty tables) but I get the following error for each table that is there:
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
It is like it has already been done, but the Models tree in Arc is empty. Can someone shed some light over what is going on here?
Note: There is another post with a similar problem but very little info is provided so I created a new one.
Copying my comments into an answer...
I'm not sure why you are trying to discover models on that schema... are there other tables that already existed? If so, then you want to only pull those in, and not the tables that were auto-created from the built-in LoopBack models. If you try to "discover" the models that you just generated the tables from, then you will naturally have duplicate models (they are built-in, they already exist).
If you want to manage, extend, alter, whatever the built-in models then you need to create a new model and use whatever built-in model as the base:
// 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
}