canmustu
canmustu

Reputation: 2639

How to change the model class in LoopBack framework

I tried to add a property manually to model class but it is not working.

I think that it has to be done with lb command on cmd but I'm not sure.

How to add , update or remove a property on model class in Loopback framework ?

LoopBack version is 4.

Upvotes: 0

Views: 456

Answers (2)

Dave Deasy
Dave Deasy

Reputation: 326

Maybe it is because my project is set up differently, but I had to run lb4 openapi command manually to update model classes after modifying the openapi spec.

lb4 openapi --url --server --client --datasource billing

Sorry I can't provide a full answer but I have no experience of Loopback. The loopback docs, tutorials, etc. are at https://loopback.io/

Upvotes: 0

Yash Rahurikar
Yash Rahurikar

Reputation: 196

You can add, update and remove properties from a model in LB4, only thing is if you update your data structure of the model, you will have to migrate the schema for the model if you are using some database like MySql or any RDMS, in case of MongoDB you can just clean the project by using command:

npm run clean

then building the project again

npm run build

and then starting the server normal with command \

npm run start

These commands are mentioned in the script object of the package.json

If you are using MySql as the database maybe this will help

How to use auto migration with loopback 4 for mysql datasource

Hopefully, this is helpful thanks

Upvotes: 1

Related Questions