Skip to main content

Records

Read and write the records of a collection. Every action is checked against the collection's rules; superusers bypass them.

List records​

Returns a page of records. Records the listRule does not match are left out.

const page = await nb.collection("posts").getList(1, 20, {
filter: nb.filter("published = true && title ~ {:q}", { q: "next" }),
sort: "-created",
expand: "author",
});
GET /collections/{collection}/records

Path parameters

ParamTypeDescription
collectionstringCollection name or id

Query parameters

ParamTypeDescription
pagenumberOptional. Page number, from 1. Default 1.
perPagenumberOptional. Records per page, 1 to 1000. Default 30.
filterstringOptional. A filter.
sortstringOptional. Comma-separated fields, - for descending, e.g. -created,title. Default -created when the collection has that field.
expandstringOptional. Relations to load, e.g. author,comments_via_post.author. Up to 6 levels.
fieldsstringOptional. Fields to return, e.g. id,title,expand.author.name.
skipTotalbooleanOptional. true skips counting; totals are then -1.

Responses

{
"page": 1,
"perPage": 20,
"totalItems": 2,
"totalPages": 1,
"items": [
{
"collectionId": "c1a2b3c4d5e6f7g",
"collectionName": "posts",
"id": "k3j2h1g9xa0b1c2",
"title": "Next.js tips",
"published": true,
"author": "u7v8w9x0y1z2a3b",
"created": "2026-10-19T09:30:00.000Z",
"expand": {
"author": { "collectionName": "users", "id": "u7v8w9x0y1z2a3b", "name": "Ann" }
}
}
]
}

View a record​

Returns one record. A record the viewRule does not match is a 404.

const post = await nb.collection("posts").getOne("k3j2h1g9xa0b1c2", {
expand: "author",
});
GET /collections/{collection}/records/{id}

Path parameters

ParamTypeDescription
collectionstringCollection name or id
idstringRecord id

Query parameters: expand and fields, as for listing.

Responses

{
"collectionId": "c1a2b3c4d5e6f7g",
"collectionName": "posts",
"id": "k3j2h1g9xa0b1c2",
"title": "Next.js tips",
"published": true,
"created": "2026-10-19T09:30:00.000Z"
}

Create a record​

Creates a record. The createRule is checked against the new record before it is inserted.

const post = await nb.collection("posts").create({
title: "Hello",
author: "u7v8w9x0y1z2a3b",
});
POST /collections/{collection}/records

Body: a JSON object of field values. id is optional: 15 characters from a-z0-9, generated when left out. For auth collections, also send password and passwordConfirm.

Query parameters: expand and fields, applied to the returned record.

Responses

The created record, as for viewing.

Update a record​

Changes the fields you send. A record the updateRule does not match is a 404, and the rule is checked before validation, so its errors never reveal a record the caller cannot change.

await nb.collection("posts").update("k3j2h1g9xa0b1c2", {
title: "Hello again",
"views+": 1,
});
PATCH /collections/{collection}/records/{id}

Body: a JSON object of field values, and these modifiers:

KeyField typesEffect
field+numberadds the value
field-numbersubtracts the value
field+multiple select or relationappends values
+fieldmultiple select or relationprepends values
field-multiple select or relationremoves values

For auth collections, changing password needs passwordConfirm and oldPassword (unless the caller is a superuser or matches the manageRule). A password change signs out the record's other sessions.

Query parameters: expand and fields, applied to the returned record.

Responses

The updated record.

Delete a record​

Deletes a record and, through relation fields, deletes or clears the records that point at it (see Relations).

await nb.collection("posts").delete("k3j2h1g9xa0b1c2");
DELETE /collections/{collection}/records/{id}

Responses

No body.