简体   繁体   中英

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.

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM