CRUD Operations

save

  • Returns: Model | { data: Model }

Save or update a model in the database, then return the instance.

When uploading files, the Content-Type will be set to multipart/form-data .

create

const model = new Model({ foo: 'bar' })

model.save()
const model = new Model()

model.foo = 'bar'

model.save()
POST /resource

update

const model = await Model.find(1)

model.foo = 'bar'

model.save()
PUT /resource/1

patch

  • Returns: Model | { data: Model }

Make a PATCH request to update a model in the database, then return the instance.

const model = await Model.find(1)

model.foo = 'bar'

model.patch()
PATCH /resource/1

Alias for:

model.config({ method: 'PATCH' }).save()
When uploading files, the Content-Type will be set to multipart/form-data .

delete

Delete the model from the database.

const model = await Model.find(1)

model.delete()
GET /resource/1
DELETE /resource/1