@classytic/mongokit 3.2.0 → 3.2.2
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/README.md +470 -193
- package/dist/actions/index.d.mts +9 -0
- package/dist/actions/index.mjs +15 -0
- package/dist/aggregate-BAi4Do-X.mjs +767 -0
- package/dist/aggregate-CCHI7F51.d.mts +269 -0
- package/dist/ai/index.d.mts +125 -0
- package/dist/ai/index.mjs +203 -0
- package/dist/cache-keys-C8Z9B5sw.mjs +204 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/create-BuO6xt0v.mjs +55 -0
- package/dist/custom-id.plugin-B_zIs6gE.mjs +1818 -0
- package/dist/custom-id.plugin-BzZI4gnE.d.mts +893 -0
- package/dist/index.d.mts +1012 -0
- package/dist/index.mjs +1906 -0
- package/dist/limits-DsNeCx4D.mjs +299 -0
- package/dist/logger-D8ily-PP.mjs +51 -0
- package/dist/mongooseToJsonSchema-COdDEkIJ.mjs +317 -0
- package/dist/{mongooseToJsonSchema-CaRF_bCN.d.ts → mongooseToJsonSchema-Wbvjfwkn.d.mts} +16 -89
- package/dist/pagination/PaginationEngine.d.mts +93 -0
- package/dist/pagination/PaginationEngine.mjs +196 -0
- package/dist/plugins/index.d.mts +3 -0
- package/dist/plugins/index.mjs +3 -0
- package/dist/types-D-gploPr.d.mts +1241 -0
- package/dist/utils/{index.d.ts → index.d.mts} +14 -21
- package/dist/utils/index.mjs +5 -0
- package/package.json +21 -21
- package/dist/actions/index.d.ts +0 -3
- package/dist/actions/index.js +0 -5
- package/dist/ai/index.d.ts +0 -175
- package/dist/ai/index.js +0 -206
- package/dist/chunks/chunk-2ZN65ZOP.js +0 -93
- package/dist/chunks/chunk-44KXLGPO.js +0 -388
- package/dist/chunks/chunk-DEVXDBRL.js +0 -1226
- package/dist/chunks/chunk-I7CWNAJB.js +0 -46
- package/dist/chunks/chunk-JWUAVZ3L.js +0 -8
- package/dist/chunks/chunk-UE2IEXZJ.js +0 -306
- package/dist/chunks/chunk-URLJFIR7.js +0 -22
- package/dist/chunks/chunk-VWKIKZYF.js +0 -737
- package/dist/chunks/chunk-WSFCRVEQ.js +0 -7
- package/dist/index-BDn5fSTE.d.ts +0 -516
- package/dist/index.d.ts +0 -1422
- package/dist/index.js +0 -1893
- package/dist/pagination/PaginationEngine.d.ts +0 -117
- package/dist/pagination/PaginationEngine.js +0 -3
- package/dist/plugins/index.d.ts +0 -922
- package/dist/plugins/index.js +0 -6
- package/dist/types-Jni1KgkP.d.ts +0 -780
- package/dist/utils/index.js +0 -5
package/dist/index-BDn5fSTE.d.ts
DELETED
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
import { PipelineStage, ClientSession, Model } from 'mongoose';
|
|
2
|
-
import { A as AnyDocument, v as CreateOptions, j as ObjectId, u as OperationOptions, S as SelectSpec, e as PopulateSpec, f as SortSpec, U as UpdateOptions, y as UpdateWithValidationResult, x as UpdateManyResult, w as DeleteResult, a5 as GroupResult, a6 as MinMaxResult } from './types-Jni1KgkP.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* LookupBuilder - MongoDB $lookup Utility
|
|
6
|
-
*
|
|
7
|
-
* Standalone builder for efficient custom field joins using MongoDB $lookup aggregation.
|
|
8
|
-
* Optimized for millions of records with proper index usage.
|
|
9
|
-
*
|
|
10
|
-
* Features:
|
|
11
|
-
* - Join on custom fields (slugs, SKUs, codes, etc.)
|
|
12
|
-
* - Pipeline support for complex transformations
|
|
13
|
-
* - Index-aware query building
|
|
14
|
-
* - Single vs Array result handling
|
|
15
|
-
* - Nested lookups
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // Simple lookup - join employees with departments by slug
|
|
20
|
-
* const lookup = new LookupBuilder('departments')
|
|
21
|
-
* .localField('departmentSlug')
|
|
22
|
-
* .foreignField('slug')
|
|
23
|
-
* .as('department')
|
|
24
|
-
* .single(); // Unwrap array to single object
|
|
25
|
-
*
|
|
26
|
-
* const pipeline = lookup.build();
|
|
27
|
-
* const results = await Employee.aggregate(pipeline);
|
|
28
|
-
*
|
|
29
|
-
* // Advanced lookup with pipeline
|
|
30
|
-
* const lookup = new LookupBuilder('products')
|
|
31
|
-
* .localField('productIds')
|
|
32
|
-
* .foreignField('sku')
|
|
33
|
-
* .pipeline([
|
|
34
|
-
* { $match: { status: 'active' } },
|
|
35
|
-
* { $project: { name: 1, price: 1 } }
|
|
36
|
-
* ])
|
|
37
|
-
* .as('products');
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
interface LookupOptions {
|
|
42
|
-
/** Collection to join with */
|
|
43
|
-
from: string;
|
|
44
|
-
/** Field from the input documents */
|
|
45
|
-
localField: string;
|
|
46
|
-
/** Field from the documents of the "from" collection */
|
|
47
|
-
foreignField: string;
|
|
48
|
-
/** Name of the new array field to add to the input documents */
|
|
49
|
-
as?: string;
|
|
50
|
-
/** Whether to unwrap array to single object */
|
|
51
|
-
single?: boolean;
|
|
52
|
-
/** Additional pipeline to run on the joined collection */
|
|
53
|
-
pipeline?: PipelineStage[];
|
|
54
|
-
/** Optional let variables for pipeline */
|
|
55
|
-
let?: Record<string, string>;
|
|
56
|
-
/** Query filter to apply before join (legacy, for aggregate.ts compatibility) */
|
|
57
|
-
query?: Record<string, unknown>;
|
|
58
|
-
/** Query options (legacy, for aggregate.ts compatibility) */
|
|
59
|
-
options?: {
|
|
60
|
-
session?: ClientSession;
|
|
61
|
-
};
|
|
62
|
-
/** Sanitize pipeline stages (default: true). Set false only for trusted server-side pipelines */
|
|
63
|
-
sanitize?: boolean;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Fluent builder for MongoDB $lookup aggregation stage
|
|
67
|
-
* Optimized for custom field joins at scale
|
|
68
|
-
*/
|
|
69
|
-
declare class LookupBuilder {
|
|
70
|
-
private options;
|
|
71
|
-
constructor(from?: string);
|
|
72
|
-
/**
|
|
73
|
-
* Set the collection to join with
|
|
74
|
-
*/
|
|
75
|
-
from(collection: string): this;
|
|
76
|
-
/**
|
|
77
|
-
* Set the local field (source collection)
|
|
78
|
-
* IMPORTANT: This field should be indexed for optimal performance
|
|
79
|
-
*/
|
|
80
|
-
localField(field: string): this;
|
|
81
|
-
/**
|
|
82
|
-
* Set the foreign field (target collection)
|
|
83
|
-
* IMPORTANT: This field should be indexed (preferably unique) for optimal performance
|
|
84
|
-
*/
|
|
85
|
-
foreignField(field: string): this;
|
|
86
|
-
/**
|
|
87
|
-
* Set the output field name
|
|
88
|
-
* Defaults to the collection name if not specified
|
|
89
|
-
*/
|
|
90
|
-
as(fieldName: string): this;
|
|
91
|
-
/**
|
|
92
|
-
* Mark this lookup as returning a single document
|
|
93
|
-
* Automatically unwraps the array result to a single object or null
|
|
94
|
-
*/
|
|
95
|
-
single(isSingle?: boolean): this;
|
|
96
|
-
/**
|
|
97
|
-
* Add a pipeline to filter/transform joined documents
|
|
98
|
-
* Useful for filtering, sorting, or limiting joined results
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* lookup.pipeline([
|
|
103
|
-
* { $match: { status: 'active' } },
|
|
104
|
-
* { $sort: { priority: -1 } },
|
|
105
|
-
* { $limit: 5 }
|
|
106
|
-
* ]);
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
pipeline(stages: PipelineStage[]): this;
|
|
110
|
-
/**
|
|
111
|
-
* Set let variables for use in pipeline
|
|
112
|
-
* Allows referencing local document fields in the pipeline
|
|
113
|
-
*/
|
|
114
|
-
let(variables: Record<string, string>): this;
|
|
115
|
-
/**
|
|
116
|
-
* Build the $lookup aggregation stage(s)
|
|
117
|
-
* Returns an array of pipeline stages including $lookup and optional $unwind
|
|
118
|
-
*
|
|
119
|
-
* IMPORTANT: MongoDB $lookup has two mutually exclusive forms:
|
|
120
|
-
* 1. Simple form: { from, localField, foreignField, as }
|
|
121
|
-
* 2. Pipeline form: { from, let, pipeline, as }
|
|
122
|
-
*
|
|
123
|
-
* When pipeline or let is specified, we use the pipeline form.
|
|
124
|
-
* Otherwise, we use the simpler localField/foreignField form.
|
|
125
|
-
*/
|
|
126
|
-
build(): PipelineStage[];
|
|
127
|
-
/**
|
|
128
|
-
* Build and return only the $lookup stage (without $unwind)
|
|
129
|
-
* Useful when you want to handle unwrapping yourself
|
|
130
|
-
*/
|
|
131
|
-
buildLookupOnly(): PipelineStage.Lookup;
|
|
132
|
-
/**
|
|
133
|
-
* Static helper: Create a simple lookup in one line
|
|
134
|
-
*/
|
|
135
|
-
static simple(from: string, localField: string, foreignField: string, options?: {
|
|
136
|
-
as?: string;
|
|
137
|
-
single?: boolean;
|
|
138
|
-
}): PipelineStage[];
|
|
139
|
-
/**
|
|
140
|
-
* Static helper: Create multiple lookups at once
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* const pipeline = LookupBuilder.multiple([
|
|
145
|
-
* { from: 'departments', localField: 'deptSlug', foreignField: 'slug', single: true },
|
|
146
|
-
* { from: 'managers', localField: 'managerId', foreignField: '_id', single: true }
|
|
147
|
-
* ]);
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
static multiple(lookups: LookupOptions[]): PipelineStage[];
|
|
151
|
-
/**
|
|
152
|
-
* Static helper: Create a nested lookup (lookup within lookup)
|
|
153
|
-
* Useful for multi-level joins like Order -> Product -> Category
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* // Join orders with products, then products with categories
|
|
158
|
-
* const pipeline = LookupBuilder.nested([
|
|
159
|
-
* { from: 'products', localField: 'productSku', foreignField: 'sku', as: 'product', single: true },
|
|
160
|
-
* { from: 'categories', localField: 'product.categorySlug', foreignField: 'slug', as: 'product.category', single: true }
|
|
161
|
-
* ]);
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
static nested(lookups: LookupOptions[]): PipelineStage[];
|
|
165
|
-
/**
|
|
166
|
-
* Sanitize pipeline stages by blocking dangerous stages and operators.
|
|
167
|
-
* Used internally by build() and available for external use (e.g., aggregate.ts).
|
|
168
|
-
*/
|
|
169
|
-
static sanitizePipeline(stages: PipelineStage[]): PipelineStage[];
|
|
170
|
-
/**
|
|
171
|
-
* Recursively remove dangerous operators from an expression object.
|
|
172
|
-
*/
|
|
173
|
-
private static _sanitizeDeep;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Create Actions
|
|
178
|
-
* Pure functions for document creation
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Create single document
|
|
183
|
-
*/
|
|
184
|
-
declare function create<TDoc = AnyDocument>(Model: Model<TDoc>, data: Record<string, unknown>, options?: CreateOptions): Promise<TDoc>;
|
|
185
|
-
/**
|
|
186
|
-
* Create multiple documents
|
|
187
|
-
*/
|
|
188
|
-
declare function createMany<TDoc = AnyDocument>(Model: Model<TDoc>, dataArray: Record<string, unknown>[], options?: CreateOptions): Promise<TDoc[]>;
|
|
189
|
-
/**
|
|
190
|
-
* Create with defaults (useful for initialization)
|
|
191
|
-
*/
|
|
192
|
-
declare function createDefault<TDoc = AnyDocument>(Model: Model<TDoc>, overrides?: Record<string, unknown>, options?: CreateOptions): Promise<TDoc>;
|
|
193
|
-
/**
|
|
194
|
-
* Upsert (create or update)
|
|
195
|
-
*/
|
|
196
|
-
declare function upsert<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, data: Record<string, unknown>, options?: {
|
|
197
|
-
session?: ClientSession;
|
|
198
|
-
updatePipeline?: boolean;
|
|
199
|
-
}): Promise<TDoc | null>;
|
|
200
|
-
|
|
201
|
-
declare const create$1_create: typeof create;
|
|
202
|
-
declare const create$1_createDefault: typeof createDefault;
|
|
203
|
-
declare const create$1_createMany: typeof createMany;
|
|
204
|
-
declare const create$1_upsert: typeof upsert;
|
|
205
|
-
declare namespace create$1 {
|
|
206
|
-
export { create$1_create as create, create$1_createDefault as createDefault, create$1_createMany as createMany, create$1_upsert as upsert };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Read Actions
|
|
211
|
-
* Pure functions for document retrieval
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Get document by ID
|
|
216
|
-
*
|
|
217
|
-
* @param Model - Mongoose model
|
|
218
|
-
* @param id - Document ID
|
|
219
|
-
* @param options - Query options
|
|
220
|
-
* @returns Document or null
|
|
221
|
-
* @throws Error if document not found and throwOnNotFound is true
|
|
222
|
-
*/
|
|
223
|
-
declare function getById<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: OperationOptions): Promise<TDoc | null>;
|
|
224
|
-
/**
|
|
225
|
-
* Get document by query
|
|
226
|
-
*
|
|
227
|
-
* @param Model - Mongoose model
|
|
228
|
-
* @param query - MongoDB query
|
|
229
|
-
* @param options - Query options
|
|
230
|
-
* @returns Document or null
|
|
231
|
-
* @throws Error if document not found and throwOnNotFound is true
|
|
232
|
-
*/
|
|
233
|
-
declare function getByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: OperationOptions): Promise<TDoc | null>;
|
|
234
|
-
/**
|
|
235
|
-
* Get document by query without throwing (returns null if not found)
|
|
236
|
-
*/
|
|
237
|
-
declare function tryGetByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: Omit<OperationOptions, 'throwOnNotFound'>): Promise<TDoc | null>;
|
|
238
|
-
/**
|
|
239
|
-
* Get all documents (basic query without pagination)
|
|
240
|
-
* For pagination, use Repository.paginate() or Repository.stream()
|
|
241
|
-
*/
|
|
242
|
-
declare function getAll<TDoc = AnyDocument>(Model: Model<TDoc>, query?: Record<string, unknown>, options?: {
|
|
243
|
-
select?: SelectSpec;
|
|
244
|
-
populate?: PopulateSpec;
|
|
245
|
-
sort?: SortSpec;
|
|
246
|
-
limit?: number;
|
|
247
|
-
skip?: number;
|
|
248
|
-
lean?: boolean;
|
|
249
|
-
session?: ClientSession;
|
|
250
|
-
}): Promise<TDoc[]>;
|
|
251
|
-
/**
|
|
252
|
-
* Get or create document (upsert)
|
|
253
|
-
*/
|
|
254
|
-
declare function getOrCreate<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, createData: Record<string, unknown>, options?: {
|
|
255
|
-
session?: ClientSession;
|
|
256
|
-
updatePipeline?: boolean;
|
|
257
|
-
}): Promise<TDoc | null>;
|
|
258
|
-
/**
|
|
259
|
-
* Count documents matching query
|
|
260
|
-
*/
|
|
261
|
-
declare function count(Model: Model<any>, query?: Record<string, unknown>, options?: {
|
|
262
|
-
session?: ClientSession;
|
|
263
|
-
}): Promise<number>;
|
|
264
|
-
/**
|
|
265
|
-
* Check if document exists
|
|
266
|
-
*/
|
|
267
|
-
declare function exists(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
268
|
-
session?: ClientSession;
|
|
269
|
-
}): Promise<{
|
|
270
|
-
_id: unknown;
|
|
271
|
-
} | null>;
|
|
272
|
-
|
|
273
|
-
declare const read_count: typeof count;
|
|
274
|
-
declare const read_exists: typeof exists;
|
|
275
|
-
declare const read_getAll: typeof getAll;
|
|
276
|
-
declare const read_getById: typeof getById;
|
|
277
|
-
declare const read_getByQuery: typeof getByQuery;
|
|
278
|
-
declare const read_getOrCreate: typeof getOrCreate;
|
|
279
|
-
declare const read_tryGetByQuery: typeof tryGetByQuery;
|
|
280
|
-
declare namespace read {
|
|
281
|
-
export { read_count as count, read_exists as exists, read_getAll as getAll, read_getById as getById, read_getByQuery as getByQuery, read_getOrCreate as getOrCreate, read_tryGetByQuery as tryGetByQuery };
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Update Actions
|
|
286
|
-
* Pure functions for document updates with optimizations
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Update by ID
|
|
291
|
-
*/
|
|
292
|
-
declare function update<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, data: Record<string, unknown>, options?: UpdateOptions): Promise<TDoc>;
|
|
293
|
-
/**
|
|
294
|
-
* Update with query constraints (optimized)
|
|
295
|
-
* Returns null if constraints not met (not an error)
|
|
296
|
-
*/
|
|
297
|
-
declare function updateWithConstraints<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, data: Record<string, unknown>, constraints?: Record<string, unknown>, options?: UpdateOptions): Promise<TDoc | null>;
|
|
298
|
-
/**
|
|
299
|
-
* Validation options for smart update
|
|
300
|
-
*/
|
|
301
|
-
interface ValidationOptions {
|
|
302
|
-
buildConstraints?: (data: Record<string, unknown>) => Record<string, unknown>;
|
|
303
|
-
validateUpdate?: (existing: Record<string, unknown>, data: Record<string, unknown>) => {
|
|
304
|
-
valid: boolean;
|
|
305
|
-
message?: string;
|
|
306
|
-
violations?: Array<{
|
|
307
|
-
field: string;
|
|
308
|
-
reason: string;
|
|
309
|
-
}>;
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Update with validation (smart optimization)
|
|
314
|
-
* 1-query on success, 2-queries for detailed errors
|
|
315
|
-
*/
|
|
316
|
-
declare function updateWithValidation<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, data: Record<string, unknown>, validationOptions?: ValidationOptions, options?: UpdateOptions): Promise<UpdateWithValidationResult<TDoc>>;
|
|
317
|
-
/**
|
|
318
|
-
* Update many documents
|
|
319
|
-
*/
|
|
320
|
-
declare function updateMany(Model: Model<unknown>, query: Record<string, unknown>, data: Record<string, unknown>, options?: {
|
|
321
|
-
session?: ClientSession;
|
|
322
|
-
updatePipeline?: boolean;
|
|
323
|
-
}): Promise<UpdateManyResult>;
|
|
324
|
-
/**
|
|
325
|
-
* Update by query
|
|
326
|
-
*/
|
|
327
|
-
declare function updateByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, data: Record<string, unknown>, options?: UpdateOptions): Promise<TDoc | null>;
|
|
328
|
-
/**
|
|
329
|
-
* Increment field
|
|
330
|
-
*/
|
|
331
|
-
declare function increment<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, field: string, value?: number, options?: UpdateOptions): Promise<TDoc>;
|
|
332
|
-
/**
|
|
333
|
-
* Push to array
|
|
334
|
-
*/
|
|
335
|
-
declare function pushToArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, field: string, value: unknown, options?: UpdateOptions): Promise<TDoc>;
|
|
336
|
-
/**
|
|
337
|
-
* Pull from array
|
|
338
|
-
*/
|
|
339
|
-
declare function pullFromArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, field: string, value: unknown, options?: UpdateOptions): Promise<TDoc>;
|
|
340
|
-
|
|
341
|
-
declare const update$1_increment: typeof increment;
|
|
342
|
-
declare const update$1_pullFromArray: typeof pullFromArray;
|
|
343
|
-
declare const update$1_pushToArray: typeof pushToArray;
|
|
344
|
-
declare const update$1_update: typeof update;
|
|
345
|
-
declare const update$1_updateByQuery: typeof updateByQuery;
|
|
346
|
-
declare const update$1_updateMany: typeof updateMany;
|
|
347
|
-
declare const update$1_updateWithConstraints: typeof updateWithConstraints;
|
|
348
|
-
declare const update$1_updateWithValidation: typeof updateWithValidation;
|
|
349
|
-
declare namespace update$1 {
|
|
350
|
-
export { update$1_increment as increment, update$1_pullFromArray as pullFromArray, update$1_pushToArray as pushToArray, update$1_update as update, update$1_updateByQuery as updateByQuery, update$1_updateMany as updateMany, update$1_updateWithConstraints as updateWithConstraints, update$1_updateWithValidation as updateWithValidation };
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Delete Actions
|
|
355
|
-
* Pure functions for document deletion
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Delete by ID
|
|
360
|
-
*/
|
|
361
|
-
declare function deleteById(Model: Model<any>, id: string | ObjectId, options?: {
|
|
362
|
-
session?: ClientSession;
|
|
363
|
-
query?: Record<string, unknown>;
|
|
364
|
-
}): Promise<DeleteResult>;
|
|
365
|
-
/**
|
|
366
|
-
* Delete many documents
|
|
367
|
-
*/
|
|
368
|
-
declare function deleteMany(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
369
|
-
session?: ClientSession;
|
|
370
|
-
}): Promise<DeleteResult>;
|
|
371
|
-
/**
|
|
372
|
-
* Delete by query
|
|
373
|
-
*/
|
|
374
|
-
declare function deleteByQuery(Model: Model<any>, query: Record<string, unknown>, options?: {
|
|
375
|
-
session?: ClientSession;
|
|
376
|
-
throwOnNotFound?: boolean;
|
|
377
|
-
}): Promise<DeleteResult>;
|
|
378
|
-
/**
|
|
379
|
-
* Soft delete (set deleted flag)
|
|
380
|
-
*/
|
|
381
|
-
declare function softDelete<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
382
|
-
session?: ClientSession;
|
|
383
|
-
userId?: string;
|
|
384
|
-
}): Promise<DeleteResult>;
|
|
385
|
-
/**
|
|
386
|
-
* Restore soft deleted document
|
|
387
|
-
*/
|
|
388
|
-
declare function restore<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
|
|
389
|
-
session?: ClientSession;
|
|
390
|
-
}): Promise<DeleteResult>;
|
|
391
|
-
|
|
392
|
-
declare const _delete_deleteById: typeof deleteById;
|
|
393
|
-
declare const _delete_deleteByQuery: typeof deleteByQuery;
|
|
394
|
-
declare const _delete_deleteMany: typeof deleteMany;
|
|
395
|
-
declare const _delete_restore: typeof restore;
|
|
396
|
-
declare const _delete_softDelete: typeof softDelete;
|
|
397
|
-
declare namespace _delete {
|
|
398
|
-
export { _delete_deleteById as deleteById, _delete_deleteByQuery as deleteByQuery, _delete_deleteMany as deleteMany, _delete_restore as restore, _delete_softDelete as softDelete };
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Aggregate Actions
|
|
403
|
-
* MongoDB aggregation pipeline operations
|
|
404
|
-
*/
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Execute aggregation pipeline
|
|
408
|
-
*/
|
|
409
|
-
declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: PipelineStage[], options?: {
|
|
410
|
-
session?: ClientSession;
|
|
411
|
-
}): Promise<TResult[]>;
|
|
412
|
-
/**
|
|
413
|
-
* Aggregate with pagination using native MongoDB $facet
|
|
414
|
-
* WARNING: $facet results must be <16MB. For larger results (limit >1000),
|
|
415
|
-
* consider using Repository.aggregatePaginate() or splitting into separate queries.
|
|
416
|
-
*/
|
|
417
|
-
declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
|
|
418
|
-
page?: number;
|
|
419
|
-
limit?: number;
|
|
420
|
-
session?: ClientSession;
|
|
421
|
-
}): Promise<{
|
|
422
|
-
docs: TDoc[];
|
|
423
|
-
total: number;
|
|
424
|
-
page: number;
|
|
425
|
-
limit: number;
|
|
426
|
-
pages: number;
|
|
427
|
-
hasNext: boolean;
|
|
428
|
-
hasPrev: boolean;
|
|
429
|
-
}>;
|
|
430
|
-
/**
|
|
431
|
-
* Group documents by field value
|
|
432
|
-
*/
|
|
433
|
-
declare function groupBy(Model: Model<any>, field: string, options?: {
|
|
434
|
-
limit?: number;
|
|
435
|
-
session?: ClientSession;
|
|
436
|
-
}): Promise<GroupResult[]>;
|
|
437
|
-
/**
|
|
438
|
-
* Count by field values
|
|
439
|
-
*/
|
|
440
|
-
declare function countBy(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
441
|
-
session?: ClientSession;
|
|
442
|
-
}): Promise<GroupResult[]>;
|
|
443
|
-
/**
|
|
444
|
-
* Lookup (join) with another collection
|
|
445
|
-
*
|
|
446
|
-
* MongoDB $lookup has two mutually exclusive forms:
|
|
447
|
-
* 1. Simple form: { from, localField, foreignField, as }
|
|
448
|
-
* 2. Pipeline form: { from, let, pipeline, as }
|
|
449
|
-
*
|
|
450
|
-
* This function automatically selects the appropriate form based on parameters.
|
|
451
|
-
*/
|
|
452
|
-
declare function lookup<TDoc = AnyDocument>(Model: Model<TDoc>, lookupOptions: LookupOptions): Promise<TDoc[]>;
|
|
453
|
-
/**
|
|
454
|
-
* Unwind array field
|
|
455
|
-
*/
|
|
456
|
-
declare function unwind<TDoc = AnyDocument>(Model: Model<TDoc>, field: string, options?: {
|
|
457
|
-
preserveEmpty?: boolean;
|
|
458
|
-
session?: ClientSession;
|
|
459
|
-
}): Promise<TDoc[]>;
|
|
460
|
-
/**
|
|
461
|
-
* Facet search (multiple aggregations in one query)
|
|
462
|
-
*/
|
|
463
|
-
declare function facet<TResult = Record<string, unknown[]>>(Model: Model<any>, facets: Record<string, PipelineStage[]>, options?: {
|
|
464
|
-
session?: ClientSession;
|
|
465
|
-
}): Promise<TResult[]>;
|
|
466
|
-
/**
|
|
467
|
-
* Get distinct values
|
|
468
|
-
*/
|
|
469
|
-
declare function distinct<T = unknown>(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
470
|
-
session?: ClientSession;
|
|
471
|
-
}): Promise<T[]>;
|
|
472
|
-
/**
|
|
473
|
-
* Calculate sum
|
|
474
|
-
*/
|
|
475
|
-
declare function sum(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
476
|
-
session?: ClientSession;
|
|
477
|
-
}): Promise<number>;
|
|
478
|
-
/**
|
|
479
|
-
* Calculate average
|
|
480
|
-
*/
|
|
481
|
-
declare function average(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
482
|
-
session?: ClientSession;
|
|
483
|
-
}): Promise<number>;
|
|
484
|
-
/**
|
|
485
|
-
* Min/Max
|
|
486
|
-
*/
|
|
487
|
-
declare function minMax(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
|
|
488
|
-
session?: ClientSession;
|
|
489
|
-
}): Promise<MinMaxResult>;
|
|
490
|
-
|
|
491
|
-
declare const aggregate$1_aggregate: typeof aggregate;
|
|
492
|
-
declare const aggregate$1_aggregatePaginate: typeof aggregatePaginate;
|
|
493
|
-
declare const aggregate$1_average: typeof average;
|
|
494
|
-
declare const aggregate$1_countBy: typeof countBy;
|
|
495
|
-
declare const aggregate$1_distinct: typeof distinct;
|
|
496
|
-
declare const aggregate$1_facet: typeof facet;
|
|
497
|
-
declare const aggregate$1_groupBy: typeof groupBy;
|
|
498
|
-
declare const aggregate$1_lookup: typeof lookup;
|
|
499
|
-
declare const aggregate$1_minMax: typeof minMax;
|
|
500
|
-
declare const aggregate$1_sum: typeof sum;
|
|
501
|
-
declare const aggregate$1_unwind: typeof unwind;
|
|
502
|
-
declare namespace aggregate$1 {
|
|
503
|
-
export { aggregate$1_aggregate as aggregate, aggregate$1_aggregatePaginate as aggregatePaginate, aggregate$1_average as average, aggregate$1_countBy as countBy, aggregate$1_distinct as distinct, aggregate$1_facet as facet, aggregate$1_groupBy as groupBy, aggregate$1_lookup as lookup, aggregate$1_minMax as minMax, aggregate$1_sum as sum, aggregate$1_unwind as unwind };
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Repository Actions
|
|
508
|
-
* Modular, composable data access operations
|
|
509
|
-
*/
|
|
510
|
-
|
|
511
|
-
declare const index_read: typeof read;
|
|
512
|
-
declare namespace index {
|
|
513
|
-
export { aggregate$1 as aggregate, create$1 as create, _delete as deleteActions, index_read as read, update$1 as update };
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
export { type LookupOptions as L, _delete as _, LookupBuilder as a, aggregate$1 as b, create$1 as c, index as i, read as r, update$1 as u };
|