Once you have defined a model, then you can use create, read, update, and delete (CRUD) operations to add data to the model, manipulate the data, and query it. All LoopBack models that are connected to persistent data stores (such as a database) automatically have the CRUD operations of the PersistedModel class.
操作 | REST | LoopBack model method (Node API)* | 对应的SQL操作 |
---|---|---|---|
Create | create()* | INSERT | |
Read (Retrieve) | GET /modelName?filter=... | find()* | SELECT |
Update (Modify) | updateAll()* | UPDATE | |
Delete (Destroy) | DELETE /modelName/modelID | destroyAll()* | DELETE |
*Methods listed are just prominent examples; other methods may provide similar functionality; for example, in addition to find()
, there are also findById()
, findOne()
, and findOrCreate()
.
See the following articles for more information: