CouchDB adapter for Decaf.ts
Interfaces
- CreateIndexRequest
Defines the structure and configuration for a new Mango index
- MangoExecutionStats
Provides detailed metrics about query execution including document and key examination counts
- MangoQuery
Interface for defining complete Mango queries with selectors, sorting, pagination, and other options
- MangoResponse
Contains the matching documents and additional metadata about the query execution
Members
Object
# static constant CouchDBConst
String constants representing special values in CouchDB
Special constant values used in CouchDB queries
Properties:
Name | Type | Description |
---|---|---|
NULL |
string
|
String representation of null value |
Object
# static constant CouchDBGroupOperator
Constants for CouchDB logical operators used in Mango queries
Mapping of logical operator names to CouchDB Mango query operators
Properties:
Name | Type | Description |
---|---|---|
AND |
string
|
Logical AND operator ($and) |
OR |
string
|
Logical OR operator ($or) |
CouchDBKeysType
# static constant CouchDBKeys
Collection of string constants for CouchDB document properties and operations
Key constants used in CouchDB operations
Object
# static constant CouchDBOperator
Constants for CouchDB comparison operators used in Mango queries
Mapping of operator names to CouchDB Mango query operators
Properties:
Name | Type | Description |
---|---|---|
EQUAL |
string
|
Equality operator ($eq) |
DIFFERENT |
string
|
Inequality operator ($ne) |
BIGGER |
string
|
Greater than operator ($gt) |
BIGGER_EQ |
string
|
Greater than or equal operator ($gte) |
SMALLER |
string
|
Less than operator ($lt) |
SMALLER_EQ |
string
|
Less than or equal operator ($lte) |
NOT |
string
|
Negation operator ($not) |
IN |
string
|
In array operator ($in) |
REGEXP |
string
|
Regular expression operator ($regex) |
# static constant CouchDBQueryLimit
Maximum number of documents to return in a single query
Default query limit for CouchDB queries
# static constant reservedAttributes
Matches any attribute that starts with an underscore
Regular expression to identify reserved attributes in CouchDB
# inner constant VERSION
The version string of the for-couchdb package
Stores the current package version
Methods
# static generateIndexDoc(attribute, tableName, compositionsopt, orderopt, separatoropt) → {CreateIndexRequest}
Creates a complete CreateIndexRequest object for defining a CouchDB index based on specified parameters
Generates a CouchDB index configuration
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
attribute |
string
|
The primary attribute for the index |
||
tableName |
string
|
The name of the table |
||
compositions |
Array.<string>
|
<optional> |
Optional additional attributes to include in the index |
|
order |
OrderDirection
|
<optional> |
Optional sort order for the index |
|
separator |
string
|
<optional> |
DefaultSeparator | The separator to use between parts of the index name |
The complete index configuration object
# static generateIndexName(attribute, tableName, compositionsopt, orderopt, separatoropt) → {string}
Creates a standardized name for a CouchDB index based on the table, attribute, compositions, and order
Generates a name for a CouchDB index
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
attribute |
string
|
The primary attribute for the index |
||
tableName |
string
|
The name of the table |
||
compositions |
Array.<string>
|
<optional> |
Optional additional attributes to include in the index |
|
order |
OrderDirection
|
<optional> |
Optional sort order for the index |
|
separator |
string
|
<optional> |
DefaultSeparator | The separator to use between parts of the index name |
The generated index name
string
# static generateIndexes(models) → {Array.<CreateIndexRequest>}
Creates a set of CouchDB index configurations based on the metadata of the provided models
Generates CouchDB index configurations for models
Parameters:
Name | Type | Description |
---|---|---|
models |
Array of model constructors to generate indexes for |
Array of CouchDB index configurations
Array.<CreateIndexRequest>
# static reAuth(con, user, pass) → {Promise.<any>}
Refreshes the authentication for a CouchDB connection using the provided credentials
Re-authenticates a connection to CouchDB
Parameters:
Name | Type | Description |
---|---|---|
con |
any
|
The CouchDB connection object |
user |
string
|
The username for authentication |
pass |
string
|
The password for authentication |
A promise that resolves to the authentication result
Promise.<any>
# static testReservedAttributes(attr) → {RegExpMatchArray|null}
Checks if an attribute name starts with an underscore, which indicates it's a reserved attribute in CouchDB
Tests if an attribute name is reserved in CouchDB
Parameters:
Name | Type | Description |
---|---|---|
attr |
string
|
The attribute name to test |
The match result or null if no match
RegExpMatchArray
|
null
# static translateOperators(operator) → {MangoOperator}
Converts Decaf.ts core operators to their equivalent CouchDB Mango query operators
Translates core operators to CouchDB Mango operators
Parameters:
Name | Type | Description |
---|---|---|
operator |
GroupOperator
|
Operator
|
The core operator to translate |
If no translation exists for the given operator
QueryError
The equivalent CouchDB Mango operator
MangoOperator
# static wrapDocumentScope(con, dbName, user, pass) → {any}
Creates a proxy around a CouchDB database connection that automatically re-authenticates before each operation
Wraps a CouchDB database connection with automatic re-authentication
Parameters:
Name | Type | Description |
---|---|---|
con |
any
|
The CouchDB connection object |
dbName |
string
|
The name of the database to use |
user |
string
|
The username for authentication |
pass |
string
|
The password for authentication |
The wrapped database connection object
any
Type Definitions
Object
# CouchDBKeysType
Collection of string constants for CouchDB document properties and operations
Key constants used in CouchDB operations
Properties:
Name | Type | Description |
---|---|---|
SEPARATOR |
string
|
Separator used for combining table name and ID |
ID |
string
|
CouchDB document ID field |
REV |
string
|
CouchDB document revision field |
DELETED |
string
|
CouchDB deleted document marker |
TABLE |
string
|
Table name marker |
SEQUENCE |
string
|
Sequence marker |
DDOC |
string
|
Design document marker |
NATIVE |
string
|
Native marker |
INDEX |
string
|
Index marker |
string
# MangoOperator
Union type of all possible operators that can be used in Mango queries
Operators available in Mango queries
number
|
string
|
Date
|
boolean
|
object
|
null
# MangoValue
Union type of all possible value types that can be used in Mango queries
Represents the possible value types in a Mango query
string
|
Array.<string>
|
Object
# SortOrder
Type for defining sort order in Mango queries
Represents a sort order specification in Mango queries
Properties:
Name | Type | Description |
---|---|---|
{...} |
"asc"
|
"desc"
|