You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2.0 throws that model-config.json is using 1.x format; where is the 2.x format? #27
compilerasserts that model configuration objects don't have properties, base, or plural configurations, but the docs show configuration showing these properties.
This leads to a very awkward situation when options.models is passed explicitly; I autogenerate model schemas based on a few data sources, and the validator is assuming that I want to use the _meta field and load model configurations from disk. Even if I found a way past the validator, explicit models configuration is ignored in buildAllModelInstructions.
Yes, but from a custom connector. I was unable to find satisfactory docs in the past on how to set up autodiscovery 'correctly' so I do some custom model definition munging, which is probably not ideal but should be possible, IMO.
Yes, exactly - I would read in my current models.json, apply updates and inserts, and pass that to app.boot.
On Jul 24, 2014, at 12:22 AM, Raymond Feng notifications@github.com wrote:
Does the custom connector produce the model definition in 1.x format (a json object containing multiple models keyed by model name)?
—
Reply to this email directly or view it on GitHub.
The documentation page "Model definition reference" is wrong, we need to update it for 2.0. Please see Migration guide - models for now.
I wonder if we should add back the ability to define multiple models in one JSON file as 1.x in addition to the 2.x style. What do you think?
I am rather opposed to that idea, it will add more complexity and maintenance overhead. We still need to decouple model definition (properties, options) from model configuration (datasource) for full-stack apps with an isomorphic client, which means the format of such multi-model JSON file will be different from 1.x models.json.
Yes, exactly - I would read in my current models.json, apply updates and inserts, and pass that to app.boot.
This is an interesting use case that I did not consider while working on loopback-boot 2.x.
As an immediate solution/workaround, you can use loopback-boot@1.x. It is 100% compatible with app.boot from loopback 1.x and it works with loopback 2.x too.
In the longer term, I can extend the options argument of boot/compile to allow you to supply:
Your own model instructions (i.e. an array of objects conforming to what buildAllModelInstructions returns). The compiler will not read any model-related files at all.
Your own model definitions (to replace the result of findModelDefinitions). Together with the existing options.models, it will allow you to specify all model-related data and still use the benefits which loopback-boot provides (most notably loading models in order defined by inheritance, i.e. base models are loaded before models that are extending them).
Thinking about it again, I think the second item is the best.
Maybe we should introduce the ldlVersion into the _meta property so that the boot code can tell which format the json conforms to.
I have considered that too, but since we are able to distinquish 1.x and 2.x even without an explicit version field, I'd rather defer adding that field until it is truly needed.
Also, just an aside, in the boot documentation, it's not clear to me what the difference is between model configuration and model definitions:
[models] Object
Object containing Model configurations.
[modelDefinitions] Array
List of model definitions to use. When options.modelDefinitions is provided, loopback-boot does not search filesystem and use only the models provided in this argument.
what the difference is between model configuration and model definitions
In short: model configuration is the data in server/model-config.json, model definition is the data from common/models/{name}.json (see also #27 (comment))
Activity
raymondfeng commentedon Jul 24, 2014
The doc needs to be updated. See an example at https://github.com/strongloop/loopback-example-app/blob/master/common/models/car.json
raymondfeng commentedon Jul 24, 2014
The difference is that each json contains one model in 2.0.
namebecomes a property instead of the key. For example,1.x:
{ "myModel": { "properties": {} } }2.x:
{ "name": "myModel", "properties": {} }raymondfeng commentedon Jul 24, 2014
Add @bajtos and @crandmck
STRML commentedon Jul 24, 2014
This leads to a very awkward situation when
options.modelsis passed explicitly; I autogenerate model schemas based on a few data sources, and the validator is assuming that I want to use the_metafield and load model configurations from disk. Even if I found a way past the validator, explicitmodelsconfiguration is ignored inbuildAllModelInstructions.raymondfeng commentedon Jul 24, 2014
Do you mean discovery?
STRML commentedon Jul 24, 2014
Yes, but from a custom connector. I was unable to find satisfactory docs in the past on how to set up autodiscovery 'correctly' so I do some custom model definition munging, which is probably not ideal but should be possible, IMO.
raymondfeng commentedon Jul 24, 2014
Does the custom connector produce the model definition in 1.x format (a json object containing multiple models keyed by model name)?
STRML commentedon Jul 24, 2014
Yes, exactly - I would read in my current
models.json, apply updates and inserts, and pass that toapp.boot.On Jul 24, 2014, at 12:22 AM, Raymond Feng notifications@github.com wrote:
raymondfeng commentedon Jul 24, 2014
I wonder if we should add back the ability to define multiple models in one JSON file as 1.x in addition to the 2.x style. What do you think?
bajtos commentedon Jul 24, 2014
The documentation page "Model definition reference" is wrong, we need to update it for 2.0. Please see Migration guide - models for now.
I am rather opposed to that idea, it will add more complexity and maintenance overhead. We still need to decouple model definition (properties, options) from model configuration (datasource) for full-stack apps with an isomorphic client, which means the format of such multi-model JSON file will be different from 1.x
models.json.This is an interesting use case that I did not consider while working on loopback-boot 2.x.
As an immediate solution/workaround, you can use
loopback-boot@1.x. It is 100% compatible withapp.bootfrom loopback 1.x and it works with loopback 2.x too.In the longer term, I can extend the
optionsargument ofboot/compileto allow you to supply:buildAllModelInstructionsreturns). The compiler will not read any model-related files at all.findModelDefinitions). Together with the existingoptions.models, it will allow you to specify all model-related data and still use the benefits which loopback-boot provides (most notably loading models in order defined by inheritance, i.e. base models are loaded before models that are extending them).Thinking about it again, I think the second item is the best.
raymondfeng commentedon Jul 24, 2014
Maybe we should introduce the
ldlVersioninto the _meta property so that the boot code can tell which format the json conforms to.bajtos commentedon Jul 25, 2014
I have considered that too, but since we are able to distinquish 1.x and 2.x even without an explicit version field, I'd rather defer adding that field until it is truly needed.
bajtos commentedon Aug 20, 2014
There was no activity for almost a month, I am closing the issue. Feel free to reopen if needed.
ORESoftware commentedon Oct 25, 2016
I am having this issue, is there simply a way to explicitly pass model-config.json to
?
Something like:
I am looking at the current docs for this:
https://apidocs.strongloop.com/loopback-boot/
and am not quite seeing it
ORESoftware commentedon Oct 25, 2016
Also, just an aside, in the boot documentation, it's not clear to me what the difference is between model configuration and model definitions:
anybody care to explain? thanks!
crandmck commentedon Nov 2, 2016
@davidcheung @deepakrkris ^
bajtos commentedon Nov 2, 2016
In short: model configuration is the data in
server/model-config.json, model definition is the data fromcommon/models/{name}.json(see also #27 (comment))