Search

Execute a CouchDB Mango _find query

Changed on

Executes a read-only Mango selector query against the database. This endpoint is a secure proxy that only allows _find queries and prevents any mutation operations. Queries are never persisted.

Security: Queries are validated to prevent mutations. The following are forbidden:

  • Mutation operators ($set, $update, $unset, $inc, $push, $pull)
  • Bulk operations (docs, bulk, new_edits)
  • Index creation (index, ddoc, type)
  • Map/reduce operations (map, reduce, views)
  • Skip-based pagination (use bookmark instead)

Pagination: Use bookmark for pagination, not skip. Default limit is 25, maximum is 100. Limits exceeding 100 are clamped.

Empty selector: An empty selector object {} is allowed and matches all documents (subject to the limit).

Index refresh: This endpoint forces update: false in the CouchDB request to disable index refresh during query execution.

post/query

Request

  • Base URL: https://sshf-api-330507742215.us-central1.run.app
  • URL: https://sshf-api-330507742215.us-central1.run.app/query
  • Auth: OAuth 2 (implicit, authorization URL https://accounts.google.com/o/oauth2/v2/auth)

Request body

selectorobject required

MongoDB-style query selector. An empty object {} matches all documents (subject to limit). Must not contain mutation operators like $set, $update, etc.

fieldsstring[]

Array of field names to include in results. If omitted, all fields are returned.

sortobject[]

Sort specification as an array of field-direction objects

limitinteger

Maximum number of results to return. Defaults to 25, clamped to 100.

bookmarkstring

Pagination bookmark from a previous query result

use_indexstring

Index to use for the query (design doc name or array of [design_doc, index_name])

execution_statsboolean

If true, return execution statistics with the result

Example request

{
  "selector": {
    "type": "veteran",
    "status": "Active"
  },
  "fields": [
    "_id",
    "name",
    "status",
    "phone"
  ],
  "sort": [
    {
      "name": "asc"
    }
  ],
  "bookmark": "g1AAAAG3eJzLYWBg4M",
  "use_index": "_design/my-index"
}

Response

Query executed successfully

docsobject[] required

Array of documents matching the query

bookmarkstring

Pagination bookmark for retrieving the next page of results

warningstring

Warning message from CouchDB (e.g., "no matching index found")

Changes