@classytic/mongokit 3.3.2 → 3.4.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.
@@ -1,102 +1,3 @@
1
- //#region src/utils/field-selection.ts
2
- /**
3
- * Get allowed fields for a user based on their context
4
- *
5
- * @param user - User object from request.user (or null for public)
6
- * @param preset - Field preset configuration
7
- * @returns Array of allowed field names
8
- *
9
- * @example
10
- * const fields = getFieldsForUser(request.user, {
11
- * public: ['id', 'name', 'price'],
12
- * authenticated: ['description', 'features'],
13
- * admin: ['createdAt', 'internalNotes']
14
- * });
15
- */
16
- function getFieldsForUser(user, preset) {
17
- if (!preset) throw new Error("Field preset is required");
18
- const fields = [...preset.public || []];
19
- if (user) {
20
- fields.push(...preset.authenticated || []);
21
- const roles = Array.isArray(user.roles) ? user.roles : user.roles ? [user.roles] : [];
22
- if (roles.includes("admin") || roles.includes("superadmin")) fields.push(...preset.admin || []);
23
- }
24
- return [...new Set(fields)];
25
- }
26
- /**
27
- * Get Mongoose projection string for query .select()
28
- *
29
- * @param user - User object from request.user
30
- * @param preset - Field preset configuration
31
- * @returns Space-separated field names for Mongoose .select()
32
- *
33
- * @example
34
- * const projection = getMongooseProjection(request.user, fieldPresets.gymPlans);
35
- * const plans = await GymPlan.find({ organizationId }).select(projection).lean();
36
- */
37
- function getMongooseProjection(user, preset) {
38
- return getFieldsForUser(user, preset).join(" ");
39
- }
40
- /**
41
- * Filter a single object to include only allowed fields
42
- */
43
- function filterObject(obj, allowedFields) {
44
- if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
45
- const filtered = {};
46
- for (const field of allowedFields) if (field in obj) filtered[field] = obj[field];
47
- return filtered;
48
- }
49
- /**
50
- * Filter response data to include only allowed fields
51
- *
52
- * Use this for complex responses where Mongoose projections aren't applicable:
53
- * - Aggregation pipeline results
54
- * - Data from multiple sources
55
- * - Custom computed fields
56
- *
57
- * For simple DB queries, prefer getMongooseProjection() (10x faster)
58
- *
59
- * @param data - Data to filter
60
- * @param preset - Field preset configuration
61
- * @param user - User object from request.user
62
- * @returns Filtered data
63
- *
64
- * @example
65
- * const stats = await calculateComplexStats();
66
- * const filtered = filterResponseData(stats, fieldPresets.dashboard, request.user);
67
- * return reply.send(filtered);
68
- */
69
- function filterResponseData(data, preset, user = null) {
70
- const allowedFields = getFieldsForUser(user, preset);
71
- if (Array.isArray(data)) return data.map((item) => filterObject(item, allowedFields));
72
- return filterObject(data, allowedFields);
73
- }
74
- /**
75
- * Helper to create field presets (module-level)
76
- *
77
- * Each module should define its own field preset in its own directory.
78
- * This keeps modules independent and self-contained.
79
- *
80
- * @param config - Field configuration
81
- * @returns Field preset
82
- *
83
- * @example
84
- * // In modules/gym-plan/gym-plan.fields.ts
85
- * export const gymPlanFieldPreset = createFieldPreset({
86
- * public: ['id', 'name', 'price'],
87
- * authenticated: ['features', 'description'],
88
- * admin: ['createdAt', 'updatedAt', 'internalNotes']
89
- * });
90
- */
91
- function createFieldPreset(config) {
92
- return {
93
- public: config.public || [],
94
- authenticated: config.authenticated || [],
95
- admin: config.admin || []
96
- };
97
- }
98
-
99
- //#endregion
100
1
  //#region src/utils/cache-keys.ts
101
2
  /**
102
3
  * Simple hash function for query parameters
@@ -114,8 +15,8 @@ function hashString(str) {
114
15
  function stableStringify(obj) {
115
16
  if (obj === null || obj === void 0) return "";
116
17
  if (typeof obj !== "object") return String(obj);
117
- if (Array.isArray(obj)) return "[" + obj.map(stableStringify).join(",") + "]";
118
- return "{" + Object.keys(obj).sort().map((key) => `${key}:${stableStringify(obj[key])}`).join(",") + "}";
18
+ if (Array.isArray(obj)) return `[${obj.map(stableStringify).join(",")}]`;
19
+ return `{${Object.keys(obj).sort().map((key) => `${key}:${stableStringify(obj[key])}`).join(",")}}`;
119
20
  }
120
21
  /**
121
22
  * Generate cache key for getById operations
@@ -143,9 +44,9 @@ function byIdKey(prefix, model, id, options) {
143
44
  }
144
45
  /**
145
46
  * Generate cache key for single-document queries
146
- *
47
+ *
147
48
  * Format: {prefix}:one:{model}:{queryHash}
148
- *
49
+ *
149
50
  * @example
150
51
  * byQueryKey('mk', 'User', { email: 'john@example.com' })
151
52
  * // => 'mk:one:User:a1b2c3d4'
@@ -159,13 +60,13 @@ function byQueryKey(prefix, model, version, query, options) {
159
60
  }
160
61
  /**
161
62
  * Generate cache key for paginated list queries
162
- *
63
+ *
163
64
  * Format: {prefix}:list:{model}:{version}:{queryHash}
164
- *
65
+ *
165
66
  * The version component enables efficient bulk invalidation:
166
67
  * - On any mutation, bump the version
167
68
  * - All list cache keys become invalid without scanning/deleting each
168
- *
69
+ *
169
70
  * @example
170
71
  * listQueryKey('mk', 'User', 1, { filters: { status: 'active' }, page: 1, limit: 20 })
171
72
  * // => 'mk:list:User:1:e5f6g7h8'
@@ -190,9 +91,9 @@ function listQueryKey(prefix, model, version, params) {
190
91
  }
191
92
  /**
192
93
  * Generate cache key for collection version tag
193
- *
94
+ *
194
95
  * Format: {prefix}:ver:{model}
195
- *
96
+ *
196
97
  * Used to track mutation version for list invalidation
197
98
  */
198
99
  function versionKey(prefix, model) {
@@ -200,9 +101,9 @@ function versionKey(prefix, model) {
200
101
  }
201
102
  /**
202
103
  * Generate pattern for clearing all cache keys for a model
203
- *
104
+ *
204
105
  * Format: {prefix}:*:{model}:*
205
- *
106
+ *
206
107
  * @example
207
108
  * modelPattern('mk', 'User')
208
109
  * // => 'mk:*:User:*'
@@ -218,6 +119,103 @@ function modelPattern(prefix, model) {
218
119
  function listPattern(prefix, model) {
219
120
  return `${prefix}:list:${model}:*`;
220
121
  }
221
-
222
122
  //#endregion
223
- export { modelPattern as a, filterResponseData as c, listQueryKey as i, getFieldsForUser as l, byQueryKey as n, versionKey as o, listPattern as r, createFieldPreset as s, byIdKey as t, getMongooseProjection as u };
123
+ //#region src/utils/field-selection.ts
124
+ /**
125
+ * Get allowed fields for a user based on their context
126
+ *
127
+ * @param user - User object from request.user (or null for public)
128
+ * @param preset - Field preset configuration
129
+ * @returns Array of allowed field names
130
+ *
131
+ * @example
132
+ * const fields = getFieldsForUser(request.user, {
133
+ * public: ['id', 'name', 'price'],
134
+ * authenticated: ['description', 'features'],
135
+ * admin: ['createdAt', 'internalNotes']
136
+ * });
137
+ */
138
+ function getFieldsForUser(user, preset) {
139
+ if (!preset) throw new Error("Field preset is required");
140
+ const fields = [...preset.public || []];
141
+ if (user) {
142
+ fields.push(...preset.authenticated || []);
143
+ const roles = Array.isArray(user.roles) ? user.roles : user.roles ? [user.roles] : [];
144
+ if (roles.includes("admin") || roles.includes("superadmin")) fields.push(...preset.admin || []);
145
+ }
146
+ return [...new Set(fields)];
147
+ }
148
+ /**
149
+ * Get Mongoose projection string for query .select()
150
+ *
151
+ * @param user - User object from request.user
152
+ * @param preset - Field preset configuration
153
+ * @returns Space-separated field names for Mongoose .select()
154
+ *
155
+ * @example
156
+ * const projection = getMongooseProjection(request.user, fieldPresets.gymPlans);
157
+ * const plans = await GymPlan.find({ organizationId }).select(projection).lean();
158
+ */
159
+ function getMongooseProjection(user, preset) {
160
+ return getFieldsForUser(user, preset).join(" ");
161
+ }
162
+ /**
163
+ * Filter a single object to include only allowed fields
164
+ */
165
+ function filterObject(obj, allowedFields) {
166
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
167
+ const filtered = {};
168
+ for (const field of allowedFields) if (field in obj) filtered[field] = obj[field];
169
+ return filtered;
170
+ }
171
+ /**
172
+ * Filter response data to include only allowed fields
173
+ *
174
+ * Use this for complex responses where Mongoose projections aren't applicable:
175
+ * - Aggregation pipeline results
176
+ * - Data from multiple sources
177
+ * - Custom computed fields
178
+ *
179
+ * For simple DB queries, prefer getMongooseProjection() (10x faster)
180
+ *
181
+ * @param data - Data to filter
182
+ * @param preset - Field preset configuration
183
+ * @param user - User object from request.user
184
+ * @returns Filtered data
185
+ *
186
+ * @example
187
+ * const stats = await calculateComplexStats();
188
+ * const filtered = filterResponseData(stats, fieldPresets.dashboard, request.user);
189
+ * return reply.send(filtered);
190
+ */
191
+ function filterResponseData(data, preset, user = null) {
192
+ const allowedFields = getFieldsForUser(user, preset);
193
+ if (Array.isArray(data)) return data.map((item) => filterObject(item, allowedFields));
194
+ return filterObject(data, allowedFields);
195
+ }
196
+ /**
197
+ * Helper to create field presets (module-level)
198
+ *
199
+ * Each module should define its own field preset in its own directory.
200
+ * This keeps modules independent and self-contained.
201
+ *
202
+ * @param config - Field configuration
203
+ * @returns Field preset
204
+ *
205
+ * @example
206
+ * // In modules/gym-plan/gym-plan.fields.ts
207
+ * export const gymPlanFieldPreset = createFieldPreset({
208
+ * public: ['id', 'name', 'price'],
209
+ * authenticated: ['features', 'description'],
210
+ * admin: ['createdAt', 'updatedAt', 'internalNotes']
211
+ * });
212
+ */
213
+ function createFieldPreset(config) {
214
+ return {
215
+ public: config.public || [],
216
+ authenticated: config.authenticated || [],
217
+ admin: config.admin || []
218
+ };
219
+ }
220
+ //#endregion
221
+ export { byIdKey as a, listQueryKey as c, getMongooseProjection as i, modelPattern as l, filterResponseData as n, byQueryKey as o, getFieldsForUser as r, listPattern as s, createFieldPreset as t, versionKey as u };
@@ -1,7 +1,95 @@
1
- import { C as GroupResult, F as ObjectId, G as PopulateSpec, K as ReadPreferenceType, N as MinMaxResult, R as OperationOptions, St as LookupOptions, _ as DeleteResult, at as SortSpec, ct as UpdateManyResult, et as SelectSpec, i as AnyDocument, lt as UpdateOptions, p as CreateOptions, ut as UpdateWithValidationResult } from "./types-pVY0w1Pp.mjs";
1
+ import { C as GroupResult, F as ObjectId, G as PopulateSpec, K as ReadPreferenceType, N as MinMaxResult, R as OperationOptions, St as LookupOptions, _ as DeleteResult, at as SortSpec, ct as UpdateManyResult, et as SelectSpec, i as AnyDocument, lt as UpdateOptions, p as CreateOptions, ut as UpdateWithValidationResult } from "./types-BlCwDszq.mjs";
2
2
  import { ClientSession, Model, PipelineStage } from "mongoose";
3
3
 
4
- //#region src/actions/create.d.ts
4
+ //#region src/actions/aggregate.d.ts
5
+ declare namespace aggregate_d_exports {
6
+ export { aggregate, aggregatePaginate, average, countBy, distinct, facet, groupBy, lookup, minMax, sum, unwind };
7
+ }
8
+ /**
9
+ * Execute aggregation pipeline
10
+ */
11
+ declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: PipelineStage[], options?: {
12
+ session?: ClientSession;
13
+ }): Promise<TResult[]>;
14
+ /**
15
+ * Aggregate with pagination using native MongoDB $facet
16
+ * WARNING: $facet results must be <16MB. For larger results (limit >1000),
17
+ * consider using Repository.aggregatePaginate() or splitting into separate queries.
18
+ */
19
+ declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
20
+ page?: number;
21
+ limit?: number;
22
+ session?: ClientSession;
23
+ }): Promise<{
24
+ docs: TDoc[];
25
+ total: number;
26
+ page: number;
27
+ limit: number;
28
+ pages: number;
29
+ hasNext: boolean;
30
+ hasPrev: boolean;
31
+ }>;
32
+ /**
33
+ * Group documents by field value
34
+ */
35
+ declare function groupBy(Model: Model<any>, field: string, options?: {
36
+ limit?: number;
37
+ session?: ClientSession;
38
+ }): Promise<GroupResult[]>;
39
+ /**
40
+ * Count by field values
41
+ */
42
+ declare function countBy(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
43
+ session?: ClientSession;
44
+ }): Promise<GroupResult[]>;
45
+ /**
46
+ * Lookup (join) with another collection
47
+ *
48
+ * MongoDB $lookup has two mutually exclusive forms:
49
+ * 1. Simple form: { from, localField, foreignField, as }
50
+ * 2. Pipeline form: { from, let, pipeline, as }
51
+ *
52
+ * This function automatically selects the appropriate form based on parameters.
53
+ */
54
+ declare function lookup<TDoc = AnyDocument>(Model: Model<TDoc>, lookupOptions: LookupOptions): Promise<TDoc[]>;
55
+ /**
56
+ * Unwind array field
57
+ */
58
+ declare function unwind<TDoc = AnyDocument>(Model: Model<TDoc>, field: string, options?: {
59
+ preserveEmpty?: boolean;
60
+ session?: ClientSession;
61
+ }): Promise<TDoc[]>;
62
+ /**
63
+ * Facet search (multiple aggregations in one query)
64
+ */
65
+ declare function facet<TResult = Record<string, unknown[]>>(Model: Model<any>, facets: Record<string, PipelineStage[]>, options?: {
66
+ session?: ClientSession;
67
+ }): Promise<TResult[]>;
68
+ /**
69
+ * Get distinct values
70
+ */
71
+ declare function distinct<T = unknown>(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
72
+ session?: ClientSession;
73
+ readPreference?: string;
74
+ }): Promise<T[]>;
75
+ /**
76
+ * Calculate sum
77
+ */
78
+ declare function sum(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
79
+ session?: ClientSession;
80
+ }): Promise<number>;
81
+ /**
82
+ * Calculate average
83
+ */
84
+ declare function average(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
85
+ session?: ClientSession;
86
+ }): Promise<number>;
87
+ /**
88
+ * Min/Max
89
+ */
90
+ declare function minMax(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
91
+ session?: ClientSession;
92
+ }): Promise<MinMaxResult>;
5
93
  declare namespace create_d_exports {
6
94
  export { create, createDefault, createMany, upsert };
7
95
  }
@@ -24,6 +112,42 @@ declare function upsert<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<st
24
112
  session?: ClientSession;
25
113
  updatePipeline?: boolean;
26
114
  }): Promise<TDoc | null>;
115
+ declare namespace delete_d_exports {
116
+ export { deleteById, deleteByQuery, deleteMany, restore, softDelete };
117
+ }
118
+ /**
119
+ * Delete by ID
120
+ */
121
+ declare function deleteById<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
122
+ session?: ClientSession;
123
+ query?: Record<string, unknown>;
124
+ }): Promise<DeleteResult>;
125
+ /**
126
+ * Delete many documents
127
+ */
128
+ declare function deleteMany<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: {
129
+ session?: ClientSession;
130
+ }): Promise<DeleteResult>;
131
+ /**
132
+ * Delete by query
133
+ */
134
+ declare function deleteByQuery(Model: Model<any>, query: Record<string, unknown>, options?: {
135
+ session?: ClientSession;
136
+ throwOnNotFound?: boolean;
137
+ }): Promise<DeleteResult>;
138
+ /**
139
+ * Soft delete (set deleted flag)
140
+ */
141
+ declare function softDelete<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
142
+ session?: ClientSession;
143
+ userId?: string;
144
+ }): Promise<DeleteResult>;
145
+ /**
146
+ * Restore soft deleted document
147
+ */
148
+ declare function restore<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
149
+ session?: ClientSession;
150
+ }): Promise<DeleteResult>;
27
151
  declare namespace read_d_exports {
28
152
  export { count, exists, getAll, getById, getByQuery, getOrCreate, tryGetByQuery };
29
153
  }
@@ -50,7 +174,7 @@ declare function getByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Recor
50
174
  /**
51
175
  * Get document by query without throwing (returns null if not found)
52
176
  */
53
- declare function tryGetByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: Omit<OperationOptions, "throwOnNotFound">): Promise<TDoc | null>;
177
+ declare function tryGetByQuery<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: Omit<OperationOptions, 'throwOnNotFound'>): Promise<TDoc | null>;
54
178
  /**
55
179
  * Get all documents (basic query without pagination)
56
180
  * For pagination, use Repository.paginate() or Repository.stream()
@@ -75,14 +199,14 @@ declare function getOrCreate<TDoc = AnyDocument>(Model: Model<TDoc>, query: Reco
75
199
  /**
76
200
  * Count documents matching query
77
201
  */
78
- declare function count(Model: Model<any>, query?: Record<string, unknown>, options?: {
202
+ declare function count<TDoc = AnyDocument>(Model: Model<TDoc>, query?: Record<string, unknown>, options?: {
79
203
  session?: ClientSession;
80
204
  readPreference?: ReadPreferenceType;
81
205
  }): Promise<number>;
82
206
  /**
83
207
  * Check if document exists
84
208
  */
85
- declare function exists(Model: Model<any>, query: Record<string, unknown>, options?: {
209
+ declare function exists<TDoc = AnyDocument>(Model: Model<TDoc>, query: Record<string, unknown>, options?: {
86
210
  session?: ClientSession;
87
211
  readPreference?: ReadPreferenceType;
88
212
  }): Promise<{
@@ -143,129 +267,8 @@ declare function pushToArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string
143
267
  * Pull from array
144
268
  */
145
269
  declare function pullFromArray<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, field: string, value: unknown, options?: UpdateOptions): Promise<TDoc>;
146
- declare namespace delete_d_exports {
147
- export { deleteById, deleteByQuery, deleteMany, restore, softDelete };
270
+ declare namespace index_d_exports {
271
+ export { aggregate_d_exports as aggregate, create_d_exports as create, delete_d_exports as deleteActions, read_d_exports as read, update_d_exports as update };
148
272
  }
149
- /**
150
- * Delete by ID
151
- */
152
- declare function deleteById(Model: Model<any>, id: string | ObjectId, options?: {
153
- session?: ClientSession;
154
- query?: Record<string, unknown>;
155
- }): Promise<DeleteResult>;
156
- /**
157
- * Delete many documents
158
- */
159
- declare function deleteMany(Model: Model<any>, query: Record<string, unknown>, options?: {
160
- session?: ClientSession;
161
- }): Promise<DeleteResult>;
162
- /**
163
- * Delete by query
164
- */
165
- declare function deleteByQuery(Model: Model<any>, query: Record<string, unknown>, options?: {
166
- session?: ClientSession;
167
- throwOnNotFound?: boolean;
168
- }): Promise<DeleteResult>;
169
- /**
170
- * Soft delete (set deleted flag)
171
- */
172
- declare function softDelete<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
173
- session?: ClientSession;
174
- userId?: string;
175
- }): Promise<DeleteResult>;
176
- /**
177
- * Restore soft deleted document
178
- */
179
- declare function restore<TDoc = AnyDocument>(Model: Model<TDoc>, id: string | ObjectId, options?: {
180
- session?: ClientSession;
181
- }): Promise<DeleteResult>;
182
- declare namespace aggregate_d_exports {
183
- export { aggregate, aggregatePaginate, average, countBy, distinct, facet, groupBy, lookup, minMax, sum, unwind };
184
- }
185
- /**
186
- * Execute aggregation pipeline
187
- */
188
- declare function aggregate<TResult = unknown>(Model: Model<any>, pipeline: PipelineStage[], options?: {
189
- session?: ClientSession;
190
- }): Promise<TResult[]>;
191
- /**
192
- * Aggregate with pagination using native MongoDB $facet
193
- * WARNING: $facet results must be <16MB. For larger results (limit >1000),
194
- * consider using Repository.aggregatePaginate() or splitting into separate queries.
195
- */
196
- declare function aggregatePaginate<TDoc = AnyDocument>(Model: Model<TDoc>, pipeline: PipelineStage[], options?: {
197
- page?: number;
198
- limit?: number;
199
- session?: ClientSession;
200
- }): Promise<{
201
- docs: TDoc[];
202
- total: number;
203
- page: number;
204
- limit: number;
205
- pages: number;
206
- hasNext: boolean;
207
- hasPrev: boolean;
208
- }>;
209
- /**
210
- * Group documents by field value
211
- */
212
- declare function groupBy(Model: Model<any>, field: string, options?: {
213
- limit?: number;
214
- session?: ClientSession;
215
- }): Promise<GroupResult[]>;
216
- /**
217
- * Count by field values
218
- */
219
- declare function countBy(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
220
- session?: ClientSession;
221
- }): Promise<GroupResult[]>;
222
- /**
223
- * Lookup (join) with another collection
224
- *
225
- * MongoDB $lookup has two mutually exclusive forms:
226
- * 1. Simple form: { from, localField, foreignField, as }
227
- * 2. Pipeline form: { from, let, pipeline, as }
228
- *
229
- * This function automatically selects the appropriate form based on parameters.
230
- */
231
- declare function lookup<TDoc = AnyDocument>(Model: Model<TDoc>, lookupOptions: LookupOptions): Promise<TDoc[]>;
232
- /**
233
- * Unwind array field
234
- */
235
- declare function unwind<TDoc = AnyDocument>(Model: Model<TDoc>, field: string, options?: {
236
- preserveEmpty?: boolean;
237
- session?: ClientSession;
238
- }): Promise<TDoc[]>;
239
- /**
240
- * Facet search (multiple aggregations in one query)
241
- */
242
- declare function facet<TResult = Record<string, unknown[]>>(Model: Model<any>, facets: Record<string, PipelineStage[]>, options?: {
243
- session?: ClientSession;
244
- }): Promise<TResult[]>;
245
- /**
246
- * Get distinct values
247
- */
248
- declare function distinct<T = unknown>(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
249
- session?: ClientSession;
250
- readPreference?: string;
251
- }): Promise<T[]>;
252
- /**
253
- * Calculate sum
254
- */
255
- declare function sum(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
256
- session?: ClientSession;
257
- }): Promise<number>;
258
- /**
259
- * Calculate average
260
- */
261
- declare function average(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
262
- session?: ClientSession;
263
- }): Promise<number>;
264
- /**
265
- * Min/Max
266
- */
267
- declare function minMax(Model: Model<any>, field: string, query?: Record<string, unknown>, options?: {
268
- session?: ClientSession;
269
- }): Promise<MinMaxResult>;
270
273
  //#endregion
271
- export { create_d_exports as a, read_d_exports as i, delete_d_exports as n, update_d_exports as r, aggregate_d_exports as t };
274
+ export { create_d_exports as a, delete_d_exports as i, update_d_exports as n, aggregate_d_exports as o, read_d_exports as r, index_d_exports as t };