# new CouchDBStatement(adapter)
Provides a fluent interface for building CouchDB Mango queries with type safety
Statement builder for CouchDB Mango queries
Parameters:
Name | Type | Description |
---|---|---|
adapter |
The CouchDB adapter |
Example
// Example of using CouchDBStatement
const adapter = new MyCouchDBAdapter(scope);
const statement = new CouchDBStatement<User, User[]>(adapter);
// Build a query
const users = await statement
.from(User)
.where(Condition.attribute<User>('age').gt(18))
.orderBy('lastName', 'asc')
.limit(10)
.execute();
Methods
# protected build() → {MangoQuery}
Converts the statement's conditions, selectors, and options into a CouchDB Mango query
Builds a CouchDB Mango query from the statement
If there are invalid query conditions
Error
The built Mango query
# async paginate(size) → {Promise.<Paginator.<M, R, MangoQuery>>}
Builds the query and returns a CouchDBPaginator for paginated results
Creates a paginator for the statement
Parameters:
Name | Type | Description |
---|---|---|
size |
number
|
The page size |
If there's an error building the query
InternalError
A promise that resolves to a paginator
Promise.<Paginator.<M, R, MangoQuery>>
# protected parseCondition(condition) → {MangoQuery}
Converts a Condition object into a CouchDB Mango query selector structure
Parses a condition into a CouchDB Mango query selector
Parameters:
Name | Type | Description |
---|---|---|
condition |
Condition.<M>
|
The condition to parse |
The Mango query with the parsed condition as its selector
# protected processRecord(r, pkAttr, sequenceType) → {any}
Extracts the ID from a CouchDB document and reverts it to a model instance
Processes a record from CouchDB
Parameters:
Name | Type | Description |
---|---|---|
r |
any
|
The raw record from CouchDB |
pkAttr |
The primary key attribute of the model |
|
sequenceType |
"Number"
|
"BigInt"
|
undefined
|
The type of the sequence |
The processed record
any
# async raw(rawInput) → {Promise.<R>}
Sends a raw Mango query to CouchDB and processes the results
Executes a raw Mango query
Parameters:
Name | Type | Description |
---|---|---|
rawInput |
MangoQuery
|
The raw Mango query to execute |
A promise that resolves to the query results
Promise.<R>