CouchSet

API reference

Public entrypoints, methods, helpers, and return shapes.

Concise inventory of public surfaces. Prefer the topic guides for behavior, pitfalls, and examples; this page is for what is exported and return shapes.

Entrypoints

ImportPurpose
couchset / couchset/legacyLegacy-compatible API
couchset/nextModern API and client primitives
couchset/registerRuntime TypeScript registration
couchset/register/transpile-onlyRegistration without type checking
couchset/register/type-checkRegistration with type checking

Model inventory

Reads

getById, findByIdWithMeta, getWithCas, findMany, findOne, exists, count, page

  • findMany defaults to 10 rows / page 0; findOne forces limit 1.
  • throwOnError: false converts query failures to empty / null / false / 0.
  • count and exists reject includes.
  • Key-value getById throws SDK not-found; findOne returns null.
  • findByIdWithMeta / getWithCas return { content, cas, expiryTime? }.
  • Model page returns { items, hasNext, pageInfo } with limit, page, offset, and nullable nextPage / nextOffset.

Guide: CRUD and queries, Relationships and hydration.

Writes

insert, prepareInsert, upsert, replaceById, prepareReplace, replaceIfCas, patchById, incrementById, mutateById, deleteById, consumeOnce

Soft deletion: softDeleteById, restoreById, withDeleted, onlyDeleted, withoutDefaultWhere.

Hydration: findDocById, findDocOne, hydrate.

SQL++ and keyspace

queryRows, queryOne, queryPage, bucket, keyspace, from

Indexes: indexStatements, instance / static ensureIndexes.

Low-level: getCollection, parse, parseProjection, serialize, serializeField.

Client inventory

AreaMethods
Lifecycleready, shutdown, getConnection
Registrymodel, registerModel, definitions, keyspace
CollectionsplanCollections, ensureCollections, combined provision
GSIplanIndexes, applyIndexPlan, ensureIndexes
Searchsearch, planSearchIndexes, applySearchIndexPlan
Othergeo, transaction, eventing
  • planCollections reports create / matching targets.
  • provision({ collections?, indexes?, waitForIndexes? }) returns collection results and index statements.
  • Registration provisions only with an explicit provision option.
  • keyspace(definition) renders bucket + target without connecting, provisioning, or requiring registration.

Guides: Connections, Provisioning, Search.

Transactions and scoped views

CouchsetTransaction: model(definition), attempt-bound query(statement, options) -> { rows }.

TransactionModel: nullable get / getById, insert(id, data), replace(document, data), replaceById(id, data), remove(document), query. Pass the returned transaction document to replace / remove. tx.model(definition) binds/registers on demand but never provisions.

ScopedModel: chainable named scopes, inspect(), findMany, findOne, page, exists, count; forwards withDeleted / onlyDeleted / withoutDefaultWhere while retaining scope predicates.

Guides: Provisioning and transactions, Extensions.

Composition and helpers

GroupExports
DefinitionsdefineModel, defineModelPlugin, dateCodec
Validation / hookswithModelValidator, ModelValidationError, ModelAfterHookError
Relationships / viewsjoinField, withModelScopes, ScopedModel, withModelMethods, withDocumentMethods
BulkbulkMap, withModelBulk
GeoModelGeo (withinBox, withinRadius), geoPoint, geoBounds, geoRadiusKm, radiusBounds
SearchModelSearch (query, match, vector, withinRadius, withinBox, withinPolygon, shape), buildModelSearchIndex
EventingEventing (definitions, register, define, physicalName, plan, apply, pause, remove), createEventing, createEventingWithManager, defineEventingFunction
Tests / seriescreateCouchsetTestFixture; TimeSeriesModel (chunkId, buildChunk, appendChunk, rangeQuery, range, queryRows); intervalToMilliseconds

Modern runtime exports also include singleton helpers: couchset, couchsetServerless, ready, ping, health, shutdown, ensureIndexes, CouchbaseConnection, startCouchbase, startCouchbaseServerless, parseDatabaseUrl, getConnectionOptions, connectionOptions, plus query builders (QueryBuilder, selectBuilder, buildSelectExpr, buildWhereClauseExpr, buildIndexExpr, buildSelectArrayExpr, query exception classes/dictionaries, parseStringSelectExpr, escapeReservedWords, CustomQuery, Pagination, createUpdate).

Type-only exports cover model / read / query / include / index / TTL / connection / pagination / search / geo / plugin / hook / instrumentation / Eventing / transaction / time-series contracts — they do not exist at runtime.

Internal client helpers (UUID, keyspace, index, raw where builders) are not package-root exports. Lower-level public builders do not automatically apply model filters, codecs, validation, hooks, or authorization.

Key returns

ShapeFields
Model page{ items, hasNext, pageInfo: { limit, page, offset, nextPage, nextOffset } }
Raw query page{ items, hasNext, params }
CAS read{ content, cas, expiryTime? }
Consume{ status: 'consumed' | 'missing' | 'conflict' }
Bulk item{ index, status: 'fulfilled', value } / { index, status: 'rejected', error } / { index, status: 'skipped' }

SDK options and results retain Couchbase SDK types. Refer to that SDK for durability, timeout, consistency, mutation token, Search, and transaction option details.

See also

On this page