@decaf-ts/for-couchdb 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/adapter.cjs +38 -32
- package/lib/cjs/adapter.cjs.map +1 -0
- package/lib/cjs/constants.cjs +1 -0
- package/lib/cjs/constants.cjs.map +1 -0
- package/lib/cjs/decorators.cjs +1 -0
- package/lib/cjs/decorators.cjs.map +1 -0
- package/lib/cjs/errors.cjs +1 -0
- package/lib/cjs/errors.cjs.map +1 -0
- package/lib/cjs/index.cjs +2 -1
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/indexes/generator.cjs +17 -16
- package/lib/cjs/indexes/generator.cjs.map +1 -0
- package/lib/cjs/indexes/index.cjs +1 -0
- package/lib/cjs/indexes/index.cjs.map +1 -0
- package/lib/cjs/metadata.cjs +1 -0
- package/lib/cjs/metadata.cjs.map +1 -0
- package/lib/cjs/query/Paginator.cjs +1 -0
- package/lib/cjs/query/Paginator.cjs.map +1 -0
- package/lib/cjs/query/Statement.cjs +37 -36
- package/lib/cjs/query/Statement.cjs.map +1 -0
- package/lib/cjs/query/constants.cjs +1 -0
- package/lib/cjs/query/constants.cjs.map +1 -0
- package/lib/cjs/query/index.cjs +1 -0
- package/lib/cjs/query/index.cjs.map +1 -0
- package/lib/cjs/query/translate.cjs +3 -2
- package/lib/cjs/query/translate.cjs.map +1 -0
- package/lib/cjs/repository.cjs +8 -7
- package/lib/cjs/repository.cjs.map +1 -0
- package/lib/cjs/types.cjs +1 -0
- package/lib/cjs/types.cjs.map +1 -0
- package/lib/cjs/utils.cjs +9 -8
- package/lib/cjs/utils.cjs.map +1 -0
- package/lib/cjs/views/generator.cjs +9 -8
- package/lib/cjs/views/generator.cjs.map +1 -0
- package/lib/cjs/views/index.cjs +1 -0
- package/lib/cjs/views/index.cjs.map +1 -0
- package/lib/cjs/views/types.cjs +1 -0
- package/lib/cjs/views/types.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/adapter.d.cts +296 -0
- package/lib/types/adapter.d.mts +296 -0
- package/lib/types/constants.d.cts +42 -0
- package/lib/types/constants.d.mts +42 -0
- package/lib/types/decorators.d.cts +8 -0
- package/lib/types/decorators.d.mts +8 -0
- package/lib/types/errors.d.cts +21 -0
- package/lib/types/errors.d.mts +21 -0
- package/lib/types/index.d.cts +28 -0
- package/lib/types/index.d.mts +28 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/indexes/generator.d.cts +51 -0
- package/lib/types/indexes/generator.d.mts +51 -0
- package/lib/types/indexes/index.d.cts +1 -0
- package/lib/types/indexes/index.d.mts +1 -0
- package/lib/types/metadata.d.cts +4 -0
- package/lib/types/metadata.d.mts +4 -0
- package/lib/types/query/Paginator.d.cts +105 -0
- package/lib/types/query/Paginator.d.mts +105 -0
- package/lib/types/query/Statement.d.cts +195 -0
- package/lib/types/query/Statement.d.mts +195 -0
- package/lib/types/query/constants.d.cts +47 -0
- package/lib/types/query/constants.d.mts +47 -0
- package/lib/types/query/index.d.cts +4 -0
- package/lib/types/query/index.d.mts +4 -0
- package/lib/types/query/translate.d.cts +34 -0
- package/lib/types/query/translate.d.mts +34 -0
- package/lib/types/repository.d.cts +39 -0
- package/lib/types/repository.d.mts +39 -0
- package/lib/types/types.d.cts +166 -0
- package/lib/types/types.d.mts +166 -0
- package/lib/types/utils.d.cts +112 -0
- package/lib/types/utils.d.mts +112 -0
- package/lib/types/views/generator.d.cts +13 -0
- package/lib/types/views/generator.d.mts +13 -0
- package/lib/types/views/index.d.cts +2 -0
- package/lib/types/views/index.d.mts +2 -0
- package/lib/types/views/types.d.cts +30 -0
- package/lib/types/views/types.d.mts +30 -0
- package/package.json +4 -4
- package/lib/cjs/adapter.js.map +0 -1
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/decorators.js.map +0 -1
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/indexes/generator.js.map +0 -1
- package/lib/cjs/indexes/index.js.map +0 -1
- package/lib/cjs/metadata.js.map +0 -1
- package/lib/cjs/query/Paginator.js.map +0 -1
- package/lib/cjs/query/Statement.js.map +0 -1
- package/lib/cjs/query/constants.js.map +0 -1
- package/lib/cjs/query/index.js.map +0 -1
- package/lib/cjs/query/translate.js.map +0 -1
- package/lib/cjs/repository.js.map +0 -1
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
- package/lib/cjs/views/generator.js.map +0 -1
- package/lib/cjs/views/index.js.map +0 -1
- package/lib/cjs/views/types.js.map +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Adapter, AdapterFlags, Paginator, RawResult, ContextualArgs, PreparedModel } from "@decaf-ts/core";
|
|
2
|
+
import { BaseError, type PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
import { type MangoQuery, ViewResponse } from "./types.cjs";
|
|
5
|
+
import { CouchDBStatement } from "./query/index.cjs";
|
|
6
|
+
import { Context } from "@decaf-ts/core";
|
|
7
|
+
import { type Constructor } from "@decaf-ts/decoration";
|
|
8
|
+
import { Repository } from "@decaf-ts/core";
|
|
9
|
+
/**
|
|
10
|
+
* @description Abstract adapter for CouchDB database operations
|
|
11
|
+
* @summary Provides a base implementation for CouchDB database operations, including CRUD operations, sequence management, and error handling
|
|
12
|
+
* @template Y - The scope type
|
|
13
|
+
* @template F - The repository flags type
|
|
14
|
+
* @template C - The context type
|
|
15
|
+
* @param {Y} scope - The scope for the adapter
|
|
16
|
+
* @param {string} flavour - The flavour of the adapter
|
|
17
|
+
* @param {string} [alias] - Optional alias for the adapter
|
|
18
|
+
* @class
|
|
19
|
+
* @example
|
|
20
|
+
* // Example of extending CouchDBAdapter
|
|
21
|
+
* class MyCouchDBAdapter extends CouchDBAdapter<MyScope, MyFlags, MyContext> {
|
|
22
|
+
* constructor(scope: MyScope) {
|
|
23
|
+
* super(scope, 'my-couchdb', 'my-alias');
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Implement abstract methods
|
|
27
|
+
* async index<M extends Model>(...models: Constructor<M>[]): Promise<void> {
|
|
28
|
+
* // Implementation
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* async raw<R>(rawInput: MangoQuery, docsOnly: boolean): Promise<R> {
|
|
32
|
+
* // Implementation
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* async create(tableName: string, id: string | number, model: Record<string, any>, ...args: any[]): Promise<Record<string, any>> {
|
|
36
|
+
* // Implementation
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* async read(tableName: string, id: string | number, ...args: any[]): Promise<Record<string, any>> {
|
|
40
|
+
* // Implementation
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* async update(tableName: string, id: string | number, model: Record<string, any>, ...args: any[]): Promise<Record<string, any>> {
|
|
44
|
+
* // Implementation
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* async delete(tableName: string, id: string | number, ...args: any[]): Promise<Record<string, any>> {
|
|
48
|
+
* // Implementation
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare abstract class CouchDBAdapter<CONF, CONN, C extends Context<any>> extends Adapter<CONF, CONN, MangoQuery, C> {
|
|
53
|
+
protected constructor(scope: CONF, flavour: string, alias?: string);
|
|
54
|
+
/**
|
|
55
|
+
* @description Creates a new CouchDB statement for querying
|
|
56
|
+
* @summary Factory method that creates a new CouchDBStatement instance for building queries
|
|
57
|
+
* @template M - The model type
|
|
58
|
+
* @return {CouchDBStatement<M, any>} A new CouchDBStatement instance
|
|
59
|
+
*/
|
|
60
|
+
Statement<M extends Model>(overrides?: Partial<AdapterFlags>): CouchDBStatement<M, Adapter<CONF, CONN, MangoQuery, C>, any>;
|
|
61
|
+
Paginator<M extends Model>(query: MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
|
|
62
|
+
/**
|
|
63
|
+
* @description Initializes the adapter by creating indexes for all managed models
|
|
64
|
+
* @summary Sets up the necessary database indexes for all models managed by this adapter
|
|
65
|
+
* @return {Promise<void>} A promise that resolves when initialization is complete
|
|
66
|
+
*/
|
|
67
|
+
initialize(): Promise<void>;
|
|
68
|
+
repository<R extends Repository<any, Adapter<CONF, CONN, MangoQuery, C>>>(): Constructor<R>;
|
|
69
|
+
/**
|
|
70
|
+
* @description Creates indexes for the given models
|
|
71
|
+
* @summary Abstract method that must be implemented to create database indexes for the specified models
|
|
72
|
+
* @template M - The model type
|
|
73
|
+
* @param {...Constructor<M>} models - The model constructors to create indexes for
|
|
74
|
+
* @return {Promise<void>} A promise that resolves when all indexes are created
|
|
75
|
+
*/
|
|
76
|
+
protected abstract index<M extends Model>(...models: Constructor<M>[]): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* @description Executes a raw Mango query against the database
|
|
79
|
+
* @summary Abstract method that must be implemented to execute raw Mango queries. Implementations may treat the first
|
|
80
|
+
* additional argument as a boolean `docsOnly` flag before the contextual arguments provided by repositories.
|
|
81
|
+
* @template R - The result type
|
|
82
|
+
* @param {MangoQuery} rawInput - The raw Mango query to execute
|
|
83
|
+
* @param {...MaybeContextualArg<C>} args - Optional `docsOnly` flag followed by contextual arguments
|
|
84
|
+
* @return {Promise<R>} A promise that resolves to the query result
|
|
85
|
+
*/
|
|
86
|
+
abstract raw<R, D extends boolean>(rawInput: MangoQuery, docsOnly: D, ...args: ContextualArgs<C>): Promise<RawResult<R, D>>;
|
|
87
|
+
/**
|
|
88
|
+
* @description Executes a CouchDB view query
|
|
89
|
+
* @summary Invokes a design document view and returns its response
|
|
90
|
+
* @template R - The view response type
|
|
91
|
+
* @param {string} ddoc - Design document name
|
|
92
|
+
* @param {string} view - View name
|
|
93
|
+
* @param {Record<string, any>} options - Mango query options
|
|
94
|
+
* @param {...ContextualArgs<C>} args - Optional contextual arguments
|
|
95
|
+
* @return {Promise<ViewResponse<R>>} The view response
|
|
96
|
+
*/
|
|
97
|
+
abstract view<R>(ddoc: string, view: string, options: Record<string, any>, ...args: ContextualArgs<C>): Promise<ViewResponse<R>>;
|
|
98
|
+
/**
|
|
99
|
+
* @description Assigns metadata to a model
|
|
100
|
+
* @summary Adds revision metadata to a model as a non-enumerable property
|
|
101
|
+
* @param {Record<string, any>} model - The model to assign metadata to
|
|
102
|
+
* @param {string} rev - The revision string to assign
|
|
103
|
+
* @return {Record<string, any>} The model with metadata assigned
|
|
104
|
+
*/
|
|
105
|
+
protected assignMetadata(model: Record<string, any>, rev: string): Record<string, any>;
|
|
106
|
+
/**
|
|
107
|
+
* @description Assigns metadata to multiple models
|
|
108
|
+
* @summary Adds revision metadata to multiple models as non-enumerable properties
|
|
109
|
+
* @param models - The models to assign metadata to
|
|
110
|
+
* @param {string[]} revs - The revision strings to assign
|
|
111
|
+
* @return The models with metadata assigned
|
|
112
|
+
*/
|
|
113
|
+
protected assignMultipleMetadata(models: Record<string, any>[], revs: string[]): Record<string, any>[];
|
|
114
|
+
prepare<M extends Model>(model: M, ...args: ContextualArgs<C>): PreparedModel;
|
|
115
|
+
/**
|
|
116
|
+
* @description Prepares a record for creation
|
|
117
|
+
* @summary Adds necessary CouchDB fields to a record before creation
|
|
118
|
+
* @param {string} tableName - The name of the table
|
|
119
|
+
* @param {string|number} id - The ID of the record
|
|
120
|
+
* @param {Record<string, any>} model - The model to prepare
|
|
121
|
+
* @return A tuple containing the tableName, id, and prepared record
|
|
122
|
+
*/
|
|
123
|
+
protected createPrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): [Constructor<M>, PrimaryKeyType, Record<string, any>, ...any[], Context];
|
|
124
|
+
/**
|
|
125
|
+
* @description Creates a new record in the database
|
|
126
|
+
* @summary Abstract method that must be implemented to create a new record
|
|
127
|
+
* @param {string} tableName - The name of the table
|
|
128
|
+
* @param {string|number} id - The ID of the record
|
|
129
|
+
* @param {Record<string, any>} model - The model to create
|
|
130
|
+
* @param {...any[]} args - Additional arguments
|
|
131
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the created record
|
|
132
|
+
*/
|
|
133
|
+
abstract create<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
134
|
+
/**
|
|
135
|
+
* @description Prepares multiple records for creation
|
|
136
|
+
* @summary Adds necessary CouchDB fields to multiple records before creation
|
|
137
|
+
* @param {string} tableName - The name of the table
|
|
138
|
+
* @param {string[]|number[]} ids - The IDs of the records
|
|
139
|
+
* @param models - The models to prepare
|
|
140
|
+
* @return A tuple containing the tableName, ids, and prepared records
|
|
141
|
+
* @throws {InternalError} If ids and models arrays have different lengths
|
|
142
|
+
*/
|
|
143
|
+
protected createAllPrefix<M extends Model>(clazz: Constructor<M>, ids: string[] | number[], models: Record<string, any>[], ...args: ContextualArgs<C>): any[];
|
|
144
|
+
/**
|
|
145
|
+
* @description Reads a record from the database
|
|
146
|
+
* @summary Abstract method that must be implemented to read a record
|
|
147
|
+
* @param {string} tableName - The name of the table
|
|
148
|
+
* @param {string|number} id - The ID of the record
|
|
149
|
+
* @param {...any[]} args - Additional arguments
|
|
150
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the read record
|
|
151
|
+
*/
|
|
152
|
+
abstract read<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
153
|
+
/**
|
|
154
|
+
* @description Prepares a record for update
|
|
155
|
+
* @summary Adds necessary CouchDB fields to a record before update
|
|
156
|
+
* @param {string} tableName - The name of the table
|
|
157
|
+
* @param {string|number} id - The ID of the record
|
|
158
|
+
* @param model - The model to prepare
|
|
159
|
+
* @param [args] - optional args for subclassing
|
|
160
|
+
* @return A tuple containing the tableName, id, and prepared record
|
|
161
|
+
* @throws {InternalError} If no revision number is found in the model
|
|
162
|
+
*/
|
|
163
|
+
updatePrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): any[];
|
|
164
|
+
/**
|
|
165
|
+
* @description Updates a record in the database
|
|
166
|
+
* @summary Abstract method that must be implemented to update a record
|
|
167
|
+
* @param {string} tableName - The name of the table
|
|
168
|
+
* @param {string|number} id - The ID of the record
|
|
169
|
+
* @param {Record<string, any>} model - The model to update
|
|
170
|
+
* @param {any[]} args - Additional arguments
|
|
171
|
+
* @return A promise that resolves to the updated record
|
|
172
|
+
*/
|
|
173
|
+
abstract update<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
174
|
+
/**
|
|
175
|
+
* @description Prepares multiple records for update
|
|
176
|
+
* @summary Adds necessary CouchDB fields to multiple records before update
|
|
177
|
+
* @param {string} tableName - The name of the table
|
|
178
|
+
* @param {string[]|number[]} ids - The IDs of the records
|
|
179
|
+
* @param models - The models to prepare
|
|
180
|
+
* @return A tuple containing the tableName, ids, and prepared records
|
|
181
|
+
* @throws {InternalError} If ids and models arrays have different lengths or if no revision number is found in a model
|
|
182
|
+
*/
|
|
183
|
+
protected updateAllPrefix<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<C>): any[];
|
|
184
|
+
/**
|
|
185
|
+
* @description Deletes a record from the database
|
|
186
|
+
* @summary Abstract method that must be implemented to delete a record
|
|
187
|
+
* @param {Constructor<M>} tableName - The name of the table
|
|
188
|
+
* @param {PrimaryKeyType} id - The ID of the record
|
|
189
|
+
* @param {any[]} args - Additional arguments
|
|
190
|
+
* @return A promise that resolves to the deleted record
|
|
191
|
+
*/
|
|
192
|
+
abstract delete<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
193
|
+
/**
|
|
194
|
+
* @description Generates a CouchDB document ID
|
|
195
|
+
* @summary Combines the table name and ID to create a CouchDB document ID
|
|
196
|
+
* @param {string} tableName - The name of the table
|
|
197
|
+
* @param {string|number} id - The ID of the record
|
|
198
|
+
* @return {string} The generated CouchDB document ID
|
|
199
|
+
*/
|
|
200
|
+
protected generateId(tableName: string, id: PrimaryKeyType): string;
|
|
201
|
+
/**
|
|
202
|
+
* @description Parses an error and converts it to a BaseError
|
|
203
|
+
* @summary Converts various error types to appropriate BaseError subtypes
|
|
204
|
+
* @param {Error|string} err - The error to parse
|
|
205
|
+
* @param {string} [reason] - Optional reason for the error
|
|
206
|
+
* @return {BaseError} The parsed error as a BaseError
|
|
207
|
+
*/
|
|
208
|
+
parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
209
|
+
/**
|
|
210
|
+
* @description Checks if an attribute is reserved
|
|
211
|
+
* @summary Determines if an attribute name is reserved in CouchDB
|
|
212
|
+
* @param {string} attr - The attribute name to check
|
|
213
|
+
* @return {boolean} True if the attribute is reserved, false otherwise
|
|
214
|
+
*/
|
|
215
|
+
protected isReserved(attr: string): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* @description Static method to parse an error and convert it to a BaseError
|
|
218
|
+
* @summary Converts various error types to appropriate BaseError subtypes based on error codes and messages
|
|
219
|
+
* @param {Error|string} err - The error to parse
|
|
220
|
+
* @param {string} [reason] - Optional reason for the error
|
|
221
|
+
* @return {BaseError} The parsed error as a BaseError
|
|
222
|
+
* @mermaid
|
|
223
|
+
* sequenceDiagram
|
|
224
|
+
* participant Caller
|
|
225
|
+
* participant parseError
|
|
226
|
+
* participant ErrorTypes
|
|
227
|
+
*
|
|
228
|
+
* Caller->>parseError: err, reason
|
|
229
|
+
* Note over parseError: Check if err is already a BaseError
|
|
230
|
+
* alt err is BaseError
|
|
231
|
+
* parseError-->>Caller: return err
|
|
232
|
+
* else err is string
|
|
233
|
+
* Note over parseError: Extract code from string
|
|
234
|
+
* alt code matches "already exist|update conflict"
|
|
235
|
+
* parseError->>ErrorTypes: new ConflictError(code)
|
|
236
|
+
* ErrorTypes-->>Caller: ConflictError
|
|
237
|
+
* else code matches "missing|deleted"
|
|
238
|
+
* parseError->>ErrorTypes: new NotFoundError(code)
|
|
239
|
+
* ErrorTypes-->>Caller: NotFoundError
|
|
240
|
+
* end
|
|
241
|
+
* else err has code property
|
|
242
|
+
* Note over parseError: Extract code and reason
|
|
243
|
+
* else err has statusCode property
|
|
244
|
+
* Note over parseError: Extract code and reason
|
|
245
|
+
* else
|
|
246
|
+
* Note over parseError: Use err.message as code
|
|
247
|
+
* end
|
|
248
|
+
*
|
|
249
|
+
* Note over parseError: Switch on code
|
|
250
|
+
* alt code is 401, 412, or 409
|
|
251
|
+
* parseError->>ErrorTypes: new ConflictError(reason)
|
|
252
|
+
* ErrorTypes-->>Caller: ConflictError
|
|
253
|
+
* else code is 404
|
|
254
|
+
* parseError->>ErrorTypes: new NotFoundError(reason)
|
|
255
|
+
* ErrorTypes-->>Caller: NotFoundError
|
|
256
|
+
* else code is 400
|
|
257
|
+
* alt code matches "No index exists"
|
|
258
|
+
* parseError->>ErrorTypes: new IndexError(err)
|
|
259
|
+
* ErrorTypes-->>Caller: IndexError
|
|
260
|
+
* else
|
|
261
|
+
* parseError->>ErrorTypes: new InternalError(err)
|
|
262
|
+
* ErrorTypes-->>Caller: InternalError
|
|
263
|
+
* end
|
|
264
|
+
* else code matches "ECONNREFUSED"
|
|
265
|
+
* parseError->>ErrorTypes: new ConnectionError(err)
|
|
266
|
+
* ErrorTypes-->>Caller: ConnectionError
|
|
267
|
+
* else
|
|
268
|
+
* parseError->>ErrorTypes: new InternalError(err)
|
|
269
|
+
* ErrorTypes-->>Caller: InternalError
|
|
270
|
+
* end
|
|
271
|
+
*/
|
|
272
|
+
protected static parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
273
|
+
/**
|
|
274
|
+
* @description Sets metadata on a model instance.
|
|
275
|
+
* @summary Attaches metadata to a model instance using a non-enumerable property.
|
|
276
|
+
* @template M - The model type that extends Model.
|
|
277
|
+
* @param {M} model - The model instance.
|
|
278
|
+
* @param {any} metadata - The metadata to attach to the model.
|
|
279
|
+
*/
|
|
280
|
+
static setMetadata<M extends Model>(model: M, metadata: any): void;
|
|
281
|
+
/**
|
|
282
|
+
* @description Gets metadata from a model instance.
|
|
283
|
+
* @summary Retrieves previously attached metadata from a model instance.
|
|
284
|
+
* @template M - The model type that extends Model.
|
|
285
|
+
* @param {M} model - The model instance.
|
|
286
|
+
* @return {any} The metadata or undefined if not found.
|
|
287
|
+
*/
|
|
288
|
+
static getMetadata<M extends Model>(model: M): any;
|
|
289
|
+
/**
|
|
290
|
+
* @description Removes metadata from a model instance.
|
|
291
|
+
* @summary Deletes the metadata property from a model instance.
|
|
292
|
+
* @template M - The model type that extends Model.
|
|
293
|
+
* @param {M} model - The model instance.
|
|
294
|
+
*/
|
|
295
|
+
static removeMetadata<M extends Model>(model: M): void;
|
|
296
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Adapter, AdapterFlags, Paginator, RawResult, ContextualArgs, PreparedModel } from "@decaf-ts/core";
|
|
2
|
+
import { BaseError, type PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
import { type MangoQuery, ViewResponse } from "./types.js";
|
|
5
|
+
import { CouchDBStatement } from "./query/index.js";
|
|
6
|
+
import { Context } from "@decaf-ts/core";
|
|
7
|
+
import { type Constructor } from "@decaf-ts/decoration";
|
|
8
|
+
import { Repository } from "@decaf-ts/core";
|
|
9
|
+
/**
|
|
10
|
+
* @description Abstract adapter for CouchDB database operations
|
|
11
|
+
* @summary Provides a base implementation for CouchDB database operations, including CRUD operations, sequence management, and error handling
|
|
12
|
+
* @template Y - The scope type
|
|
13
|
+
* @template F - The repository flags type
|
|
14
|
+
* @template C - The context type
|
|
15
|
+
* @param {Y} scope - The scope for the adapter
|
|
16
|
+
* @param {string} flavour - The flavour of the adapter
|
|
17
|
+
* @param {string} [alias] - Optional alias for the adapter
|
|
18
|
+
* @class
|
|
19
|
+
* @example
|
|
20
|
+
* // Example of extending CouchDBAdapter
|
|
21
|
+
* class MyCouchDBAdapter extends CouchDBAdapter<MyScope, MyFlags, MyContext> {
|
|
22
|
+
* constructor(scope: MyScope) {
|
|
23
|
+
* super(scope, 'my-couchdb', 'my-alias');
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Implement abstract methods
|
|
27
|
+
* async index<M extends Model>(...models: Constructor<M>[]): Promise<void> {
|
|
28
|
+
* // Implementation
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* async raw<R>(rawInput: MangoQuery, docsOnly: boolean): Promise<R> {
|
|
32
|
+
* // Implementation
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* async create(tableName: string, id: string | number, model: Record<string, any>, ...args: any[]): Promise<Record<string, any>> {
|
|
36
|
+
* // Implementation
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* async read(tableName: string, id: string | number, ...args: any[]): Promise<Record<string, any>> {
|
|
40
|
+
* // Implementation
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* async update(tableName: string, id: string | number, model: Record<string, any>, ...args: any[]): Promise<Record<string, any>> {
|
|
44
|
+
* // Implementation
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* async delete(tableName: string, id: string | number, ...args: any[]): Promise<Record<string, any>> {
|
|
48
|
+
* // Implementation
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare abstract class CouchDBAdapter<CONF, CONN, C extends Context<any>> extends Adapter<CONF, CONN, MangoQuery, C> {
|
|
53
|
+
protected constructor(scope: CONF, flavour: string, alias?: string);
|
|
54
|
+
/**
|
|
55
|
+
* @description Creates a new CouchDB statement for querying
|
|
56
|
+
* @summary Factory method that creates a new CouchDBStatement instance for building queries
|
|
57
|
+
* @template M - The model type
|
|
58
|
+
* @return {CouchDBStatement<M, any>} A new CouchDBStatement instance
|
|
59
|
+
*/
|
|
60
|
+
Statement<M extends Model>(overrides?: Partial<AdapterFlags>): CouchDBStatement<M, Adapter<CONF, CONN, MangoQuery, C>, any>;
|
|
61
|
+
Paginator<M extends Model>(query: MangoQuery, size: number, clazz: Constructor<M>): Paginator<M, any, MangoQuery>;
|
|
62
|
+
/**
|
|
63
|
+
* @description Initializes the adapter by creating indexes for all managed models
|
|
64
|
+
* @summary Sets up the necessary database indexes for all models managed by this adapter
|
|
65
|
+
* @return {Promise<void>} A promise that resolves when initialization is complete
|
|
66
|
+
*/
|
|
67
|
+
initialize(): Promise<void>;
|
|
68
|
+
repository<R extends Repository<any, Adapter<CONF, CONN, MangoQuery, C>>>(): Constructor<R>;
|
|
69
|
+
/**
|
|
70
|
+
* @description Creates indexes for the given models
|
|
71
|
+
* @summary Abstract method that must be implemented to create database indexes for the specified models
|
|
72
|
+
* @template M - The model type
|
|
73
|
+
* @param {...Constructor<M>} models - The model constructors to create indexes for
|
|
74
|
+
* @return {Promise<void>} A promise that resolves when all indexes are created
|
|
75
|
+
*/
|
|
76
|
+
protected abstract index<M extends Model>(...models: Constructor<M>[]): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* @description Executes a raw Mango query against the database
|
|
79
|
+
* @summary Abstract method that must be implemented to execute raw Mango queries. Implementations may treat the first
|
|
80
|
+
* additional argument as a boolean `docsOnly` flag before the contextual arguments provided by repositories.
|
|
81
|
+
* @template R - The result type
|
|
82
|
+
* @param {MangoQuery} rawInput - The raw Mango query to execute
|
|
83
|
+
* @param {...MaybeContextualArg<C>} args - Optional `docsOnly` flag followed by contextual arguments
|
|
84
|
+
* @return {Promise<R>} A promise that resolves to the query result
|
|
85
|
+
*/
|
|
86
|
+
abstract raw<R, D extends boolean>(rawInput: MangoQuery, docsOnly: D, ...args: ContextualArgs<C>): Promise<RawResult<R, D>>;
|
|
87
|
+
/**
|
|
88
|
+
* @description Executes a CouchDB view query
|
|
89
|
+
* @summary Invokes a design document view and returns its response
|
|
90
|
+
* @template R - The view response type
|
|
91
|
+
* @param {string} ddoc - Design document name
|
|
92
|
+
* @param {string} view - View name
|
|
93
|
+
* @param {Record<string, any>} options - Mango query options
|
|
94
|
+
* @param {...ContextualArgs<C>} args - Optional contextual arguments
|
|
95
|
+
* @return {Promise<ViewResponse<R>>} The view response
|
|
96
|
+
*/
|
|
97
|
+
abstract view<R>(ddoc: string, view: string, options: Record<string, any>, ...args: ContextualArgs<C>): Promise<ViewResponse<R>>;
|
|
98
|
+
/**
|
|
99
|
+
* @description Assigns metadata to a model
|
|
100
|
+
* @summary Adds revision metadata to a model as a non-enumerable property
|
|
101
|
+
* @param {Record<string, any>} model - The model to assign metadata to
|
|
102
|
+
* @param {string} rev - The revision string to assign
|
|
103
|
+
* @return {Record<string, any>} The model with metadata assigned
|
|
104
|
+
*/
|
|
105
|
+
protected assignMetadata(model: Record<string, any>, rev: string): Record<string, any>;
|
|
106
|
+
/**
|
|
107
|
+
* @description Assigns metadata to multiple models
|
|
108
|
+
* @summary Adds revision metadata to multiple models as non-enumerable properties
|
|
109
|
+
* @param models - The models to assign metadata to
|
|
110
|
+
* @param {string[]} revs - The revision strings to assign
|
|
111
|
+
* @return The models with metadata assigned
|
|
112
|
+
*/
|
|
113
|
+
protected assignMultipleMetadata(models: Record<string, any>[], revs: string[]): Record<string, any>[];
|
|
114
|
+
prepare<M extends Model>(model: M, ...args: ContextualArgs<C>): PreparedModel;
|
|
115
|
+
/**
|
|
116
|
+
* @description Prepares a record for creation
|
|
117
|
+
* @summary Adds necessary CouchDB fields to a record before creation
|
|
118
|
+
* @param {string} tableName - The name of the table
|
|
119
|
+
* @param {string|number} id - The ID of the record
|
|
120
|
+
* @param {Record<string, any>} model - The model to prepare
|
|
121
|
+
* @return A tuple containing the tableName, id, and prepared record
|
|
122
|
+
*/
|
|
123
|
+
protected createPrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): [Constructor<M>, PrimaryKeyType, Record<string, any>, ...any[], Context];
|
|
124
|
+
/**
|
|
125
|
+
* @description Creates a new record in the database
|
|
126
|
+
* @summary Abstract method that must be implemented to create a new record
|
|
127
|
+
* @param {string} tableName - The name of the table
|
|
128
|
+
* @param {string|number} id - The ID of the record
|
|
129
|
+
* @param {Record<string, any>} model - The model to create
|
|
130
|
+
* @param {...any[]} args - Additional arguments
|
|
131
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the created record
|
|
132
|
+
*/
|
|
133
|
+
abstract create<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
134
|
+
/**
|
|
135
|
+
* @description Prepares multiple records for creation
|
|
136
|
+
* @summary Adds necessary CouchDB fields to multiple records before creation
|
|
137
|
+
* @param {string} tableName - The name of the table
|
|
138
|
+
* @param {string[]|number[]} ids - The IDs of the records
|
|
139
|
+
* @param models - The models to prepare
|
|
140
|
+
* @return A tuple containing the tableName, ids, and prepared records
|
|
141
|
+
* @throws {InternalError} If ids and models arrays have different lengths
|
|
142
|
+
*/
|
|
143
|
+
protected createAllPrefix<M extends Model>(clazz: Constructor<M>, ids: string[] | number[], models: Record<string, any>[], ...args: ContextualArgs<C>): any[];
|
|
144
|
+
/**
|
|
145
|
+
* @description Reads a record from the database
|
|
146
|
+
* @summary Abstract method that must be implemented to read a record
|
|
147
|
+
* @param {string} tableName - The name of the table
|
|
148
|
+
* @param {string|number} id - The ID of the record
|
|
149
|
+
* @param {...any[]} args - Additional arguments
|
|
150
|
+
* @return {Promise<Record<string, any>>} A promise that resolves to the read record
|
|
151
|
+
*/
|
|
152
|
+
abstract read<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
153
|
+
/**
|
|
154
|
+
* @description Prepares a record for update
|
|
155
|
+
* @summary Adds necessary CouchDB fields to a record before update
|
|
156
|
+
* @param {string} tableName - The name of the table
|
|
157
|
+
* @param {string|number} id - The ID of the record
|
|
158
|
+
* @param model - The model to prepare
|
|
159
|
+
* @param [args] - optional args for subclassing
|
|
160
|
+
* @return A tuple containing the tableName, id, and prepared record
|
|
161
|
+
* @throws {InternalError} If no revision number is found in the model
|
|
162
|
+
*/
|
|
163
|
+
updatePrefix<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): any[];
|
|
164
|
+
/**
|
|
165
|
+
* @description Updates a record in the database
|
|
166
|
+
* @summary Abstract method that must be implemented to update a record
|
|
167
|
+
* @param {string} tableName - The name of the table
|
|
168
|
+
* @param {string|number} id - The ID of the record
|
|
169
|
+
* @param {Record<string, any>} model - The model to update
|
|
170
|
+
* @param {any[]} args - Additional arguments
|
|
171
|
+
* @return A promise that resolves to the updated record
|
|
172
|
+
*/
|
|
173
|
+
abstract update<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
174
|
+
/**
|
|
175
|
+
* @description Prepares multiple records for update
|
|
176
|
+
* @summary Adds necessary CouchDB fields to multiple records before update
|
|
177
|
+
* @param {string} tableName - The name of the table
|
|
178
|
+
* @param {string[]|number[]} ids - The IDs of the records
|
|
179
|
+
* @param models - The models to prepare
|
|
180
|
+
* @return A tuple containing the tableName, ids, and prepared records
|
|
181
|
+
* @throws {InternalError} If ids and models arrays have different lengths or if no revision number is found in a model
|
|
182
|
+
*/
|
|
183
|
+
protected updateAllPrefix<M extends Model>(clazz: Constructor<M>, ids: PrimaryKeyType[], models: Record<string, any>[], ...args: ContextualArgs<C>): any[];
|
|
184
|
+
/**
|
|
185
|
+
* @description Deletes a record from the database
|
|
186
|
+
* @summary Abstract method that must be implemented to delete a record
|
|
187
|
+
* @param {Constructor<M>} tableName - The name of the table
|
|
188
|
+
* @param {PrimaryKeyType} id - The ID of the record
|
|
189
|
+
* @param {any[]} args - Additional arguments
|
|
190
|
+
* @return A promise that resolves to the deleted record
|
|
191
|
+
*/
|
|
192
|
+
abstract delete<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
193
|
+
/**
|
|
194
|
+
* @description Generates a CouchDB document ID
|
|
195
|
+
* @summary Combines the table name and ID to create a CouchDB document ID
|
|
196
|
+
* @param {string} tableName - The name of the table
|
|
197
|
+
* @param {string|number} id - The ID of the record
|
|
198
|
+
* @return {string} The generated CouchDB document ID
|
|
199
|
+
*/
|
|
200
|
+
protected generateId(tableName: string, id: PrimaryKeyType): string;
|
|
201
|
+
/**
|
|
202
|
+
* @description Parses an error and converts it to a BaseError
|
|
203
|
+
* @summary Converts various error types to appropriate BaseError subtypes
|
|
204
|
+
* @param {Error|string} err - The error to parse
|
|
205
|
+
* @param {string} [reason] - Optional reason for the error
|
|
206
|
+
* @return {BaseError} The parsed error as a BaseError
|
|
207
|
+
*/
|
|
208
|
+
parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
209
|
+
/**
|
|
210
|
+
* @description Checks if an attribute is reserved
|
|
211
|
+
* @summary Determines if an attribute name is reserved in CouchDB
|
|
212
|
+
* @param {string} attr - The attribute name to check
|
|
213
|
+
* @return {boolean} True if the attribute is reserved, false otherwise
|
|
214
|
+
*/
|
|
215
|
+
protected isReserved(attr: string): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* @description Static method to parse an error and convert it to a BaseError
|
|
218
|
+
* @summary Converts various error types to appropriate BaseError subtypes based on error codes and messages
|
|
219
|
+
* @param {Error|string} err - The error to parse
|
|
220
|
+
* @param {string} [reason] - Optional reason for the error
|
|
221
|
+
* @return {BaseError} The parsed error as a BaseError
|
|
222
|
+
* @mermaid
|
|
223
|
+
* sequenceDiagram
|
|
224
|
+
* participant Caller
|
|
225
|
+
* participant parseError
|
|
226
|
+
* participant ErrorTypes
|
|
227
|
+
*
|
|
228
|
+
* Caller->>parseError: err, reason
|
|
229
|
+
* Note over parseError: Check if err is already a BaseError
|
|
230
|
+
* alt err is BaseError
|
|
231
|
+
* parseError-->>Caller: return err
|
|
232
|
+
* else err is string
|
|
233
|
+
* Note over parseError: Extract code from string
|
|
234
|
+
* alt code matches "already exist|update conflict"
|
|
235
|
+
* parseError->>ErrorTypes: new ConflictError(code)
|
|
236
|
+
* ErrorTypes-->>Caller: ConflictError
|
|
237
|
+
* else code matches "missing|deleted"
|
|
238
|
+
* parseError->>ErrorTypes: new NotFoundError(code)
|
|
239
|
+
* ErrorTypes-->>Caller: NotFoundError
|
|
240
|
+
* end
|
|
241
|
+
* else err has code property
|
|
242
|
+
* Note over parseError: Extract code and reason
|
|
243
|
+
* else err has statusCode property
|
|
244
|
+
* Note over parseError: Extract code and reason
|
|
245
|
+
* else
|
|
246
|
+
* Note over parseError: Use err.message as code
|
|
247
|
+
* end
|
|
248
|
+
*
|
|
249
|
+
* Note over parseError: Switch on code
|
|
250
|
+
* alt code is 401, 412, or 409
|
|
251
|
+
* parseError->>ErrorTypes: new ConflictError(reason)
|
|
252
|
+
* ErrorTypes-->>Caller: ConflictError
|
|
253
|
+
* else code is 404
|
|
254
|
+
* parseError->>ErrorTypes: new NotFoundError(reason)
|
|
255
|
+
* ErrorTypes-->>Caller: NotFoundError
|
|
256
|
+
* else code is 400
|
|
257
|
+
* alt code matches "No index exists"
|
|
258
|
+
* parseError->>ErrorTypes: new IndexError(err)
|
|
259
|
+
* ErrorTypes-->>Caller: IndexError
|
|
260
|
+
* else
|
|
261
|
+
* parseError->>ErrorTypes: new InternalError(err)
|
|
262
|
+
* ErrorTypes-->>Caller: InternalError
|
|
263
|
+
* end
|
|
264
|
+
* else code matches "ECONNREFUSED"
|
|
265
|
+
* parseError->>ErrorTypes: new ConnectionError(err)
|
|
266
|
+
* ErrorTypes-->>Caller: ConnectionError
|
|
267
|
+
* else
|
|
268
|
+
* parseError->>ErrorTypes: new InternalError(err)
|
|
269
|
+
* ErrorTypes-->>Caller: InternalError
|
|
270
|
+
* end
|
|
271
|
+
*/
|
|
272
|
+
protected static parseError<E extends BaseError>(err: Error | string, reason?: string): E;
|
|
273
|
+
/**
|
|
274
|
+
* @description Sets metadata on a model instance.
|
|
275
|
+
* @summary Attaches metadata to a model instance using a non-enumerable property.
|
|
276
|
+
* @template M - The model type that extends Model.
|
|
277
|
+
* @param {M} model - The model instance.
|
|
278
|
+
* @param {any} metadata - The metadata to attach to the model.
|
|
279
|
+
*/
|
|
280
|
+
static setMetadata<M extends Model>(model: M, metadata: any): void;
|
|
281
|
+
/**
|
|
282
|
+
* @description Gets metadata from a model instance.
|
|
283
|
+
* @summary Retrieves previously attached metadata from a model instance.
|
|
284
|
+
* @template M - The model type that extends Model.
|
|
285
|
+
* @param {M} model - The model instance.
|
|
286
|
+
* @return {any} The metadata or undefined if not found.
|
|
287
|
+
*/
|
|
288
|
+
static getMetadata<M extends Model>(model: M): any;
|
|
289
|
+
/**
|
|
290
|
+
* @description Removes metadata from a model instance.
|
|
291
|
+
* @summary Deletes the metadata property from a model instance.
|
|
292
|
+
* @template M - The model type that extends Model.
|
|
293
|
+
* @param {M} model - The model instance.
|
|
294
|
+
*/
|
|
295
|
+
static removeMetadata<M extends Model>(model: M): void;
|
|
296
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Regular expression to identify reserved attributes in CouchDB
|
|
3
|
+
* @summary Matches any attribute that starts with an underscore
|
|
4
|
+
* @const reservedAttributes
|
|
5
|
+
* @memberOf module:for-couchdb
|
|
6
|
+
*/
|
|
7
|
+
export declare const reservedAttributes: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* @description Key constants used in CouchDB operations
|
|
10
|
+
* @summary Collection of string constants for CouchDB document properties and operations
|
|
11
|
+
* @typedef {Object} CouchDBKeysType
|
|
12
|
+
* @property {string} SEPARATOR - Separator used for combining table name and ID
|
|
13
|
+
* @property {string} ID - CouchDB document ID field
|
|
14
|
+
* @property {string} REV - CouchDB document revision field
|
|
15
|
+
* @property {string} DELETED - CouchDB deleted document marker
|
|
16
|
+
* @property {string} TABLE - Table name marker
|
|
17
|
+
* @property {string} SEQUENCE - Sequence marker
|
|
18
|
+
* @property {string} DDOC - Design document marker
|
|
19
|
+
* @property {string} NATIVE - Native marker
|
|
20
|
+
* @property {string} INDEX - Index marker
|
|
21
|
+
* @memberOf module:for-couchdb
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @description Key constants used in CouchDB operations
|
|
25
|
+
* @summary Collection of string constants for CouchDB document properties and operations
|
|
26
|
+
* @const CouchDBKeys
|
|
27
|
+
* @type {CouchDBKeysType}
|
|
28
|
+
* @memberOf module:for-couchdb
|
|
29
|
+
*/
|
|
30
|
+
export declare const CouchDBKeys: {
|
|
31
|
+
SEPARATOR: string;
|
|
32
|
+
ID: string;
|
|
33
|
+
REV: string;
|
|
34
|
+
DELETED: string;
|
|
35
|
+
TABLE: string;
|
|
36
|
+
SEQUENCE: string;
|
|
37
|
+
DDOC: string;
|
|
38
|
+
NATIVE: string;
|
|
39
|
+
INDEX: string;
|
|
40
|
+
/** @description Key for CouchDB view metadata */
|
|
41
|
+
VIEW: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Regular expression to identify reserved attributes in CouchDB
|
|
3
|
+
* @summary Matches any attribute that starts with an underscore
|
|
4
|
+
* @const reservedAttributes
|
|
5
|
+
* @memberOf module:for-couchdb
|
|
6
|
+
*/
|
|
7
|
+
export declare const reservedAttributes: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* @description Key constants used in CouchDB operations
|
|
10
|
+
* @summary Collection of string constants for CouchDB document properties and operations
|
|
11
|
+
* @typedef {Object} CouchDBKeysType
|
|
12
|
+
* @property {string} SEPARATOR - Separator used for combining table name and ID
|
|
13
|
+
* @property {string} ID - CouchDB document ID field
|
|
14
|
+
* @property {string} REV - CouchDB document revision field
|
|
15
|
+
* @property {string} DELETED - CouchDB deleted document marker
|
|
16
|
+
* @property {string} TABLE - Table name marker
|
|
17
|
+
* @property {string} SEQUENCE - Sequence marker
|
|
18
|
+
* @property {string} DDOC - Design document marker
|
|
19
|
+
* @property {string} NATIVE - Native marker
|
|
20
|
+
* @property {string} INDEX - Index marker
|
|
21
|
+
* @memberOf module:for-couchdb
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @description Key constants used in CouchDB operations
|
|
25
|
+
* @summary Collection of string constants for CouchDB document properties and operations
|
|
26
|
+
* @const CouchDBKeys
|
|
27
|
+
* @type {CouchDBKeysType}
|
|
28
|
+
* @memberOf module:for-couchdb
|
|
29
|
+
*/
|
|
30
|
+
export declare const CouchDBKeys: {
|
|
31
|
+
SEPARATOR: string;
|
|
32
|
+
ID: string;
|
|
33
|
+
REV: string;
|
|
34
|
+
DELETED: string;
|
|
35
|
+
TABLE: string;
|
|
36
|
+
SEQUENCE: string;
|
|
37
|
+
DDOC: string;
|
|
38
|
+
NATIVE: string;
|
|
39
|
+
INDEX: string;
|
|
40
|
+
/** @description Key for CouchDB view metadata */
|
|
41
|
+
VIEW: string;
|
|
42
|
+
};
|