Closed fgvicente closed 3 years ago
@fgvicente Models in LoopBack 4 describe the shape of data. Behavior like CRUD operations is added by repositories. This is different from LoopBack 3.x where models implement behavior too. You can check model and migrating models from LB3 to LB4 to understand more about the differences.
in lb3...I get all model with this.... let models = app.models();
In LB4 your models are usually defined in folder src/models
, e.g. in application.ts file, you can import all model classes as
import * as models from './models';
The APIs are defined in repositories, see https://loopback.io/doc/en/lb4/Repositories.html
@fgvicente all models are binded in the application context with prefix model.
, you can get a model with ctx.get('models.' + modelName). Please take a look at https://github.com/strongloop/loopback-next/pull/5378
A better way is to use ctx.findByTag('model')
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository. This issue will be closed within 30 days of being stale.
Ok. in lb3...I get al model with this....
let models = app.models();
and I get all method for one model this...
let model = app.models[modelName]; let methods = model.sharedClass.methods()
my question... How would it be in lb4?