In LoopBack 4, models describe the shape of data, repositories provide behavior like CRUD operations, and controllers define routes (this is different from LoopBack 3.x where models implement behavior too). LB4 repositories provide a couple of create, read, update, and delete (CRUD) operations. Once you have defined these three artifacts, you can add data to the model, manipulate the data, and query it through these CRUD operations. The following is an overview of CRUD operations at different levels:
Operation | REST | LoopBack model method (Node.js API)* |
Corresponding SQL Operation |
---|---|---|---|
Create |
PUT /modelName
POST /modelName |
create()
createAll()
|
INSERT |
Read (Retrieve) | GET /modelName?filter=... | find*()
|
SELECT |
Update (Modify) |
POST /modelName
PUT /modelName |
update*()
replaceById()
|
UPDATE |
Delete (Destroy) | DELETE /modelName/modelID | delete*()
|
DELETE |
(*) Methods listed are just prominent examples; other methods may provide
similar functionality; for example: findById()
, findOne()
,
and updateAll()
. See
DefaultCrudRepository Methods API documentation
for more information.
See the following articles for more information: