BUCKET.CLOSE
Closes a cursor and releases its associated query context from the session.
Syntax
Section titled “Syntax”BUCKET.CLOSE <operation> <cursor-id>Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
operation | string | Yes | The operation type. Must be QUERY, DELETE, or UPDATE. |
cursor-id | integer | Yes | The cursor ID returned by the initial command (BUCKET., BUCKET., or BUCKET.). |
Return Value
Section titled “Return Value”Returns OK on success.
Errors
Section titled “Errors”Argument errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | Unknown '<operation>' operation | The operation type is not QUERY, DELETE, or UPDATE. |
Bucket errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | no cursor found | - |
Examples
Section titled “Examples”Close a query cursor:
> BUCKET.QUERY users '{}' BATCH 100cursor_id -> (integer) 1entries -> [...] (first 100 documents)
> BUCKET.CLOSE QUERY 1OKDouble-close returns an error:
> BUCKET.QUERY users '{}' BATCH 100cursor_id -> (integer) 1entries -> [...]
> BUCKET.CLOSE QUERY 1OK
> BUCKET.CLOSE QUERY 1(error) ERR no cursor foundClose after pagination:
> BUCKET.DELETE users '{"status": "inactive"}' BATCH 50cursor_id -> (integer) 1object_ids -> [...] (first 50 deleted)
> BUCKET.ADVANCE DELETE 1cursor_id -> (integer) 1object_ids -> [...] (next 50 deleted)
> BUCKET.CLOSE DELETE 1OKClosing one cursor does not affect others:
> BUCKET.QUERY users '{}' BATCH 10cursor_id -> (integer) 1entries -> [...]
> BUCKET.DELETE users '{"status": "inactive"}' BATCH 10cursor_id -> (integer) 2object_ids -> [...]
> BUCKET.CLOSE QUERY 1OK
> BUCKET.ADVANCE DELETE 2cursor_id -> (integer) 2object_ids -> [...] (still works)