1 | declare module 'mongoose' {
|
2 | |
3 |
|
4 |
|
5 | export type PipelineStage =
|
6 | | PipelineStage.AddFields
|
7 | | PipelineStage.Bucket
|
8 | | PipelineStage.BucketAuto
|
9 | | PipelineStage.CollStats
|
10 | | PipelineStage.Count
|
11 | | PipelineStage.Densify
|
12 | | PipelineStage.Facet
|
13 | | PipelineStage.Fill
|
14 | | PipelineStage.GeoNear
|
15 | | PipelineStage.GraphLookup
|
16 | | PipelineStage.Group
|
17 | | PipelineStage.IndexStats
|
18 | | PipelineStage.Limit
|
19 | | PipelineStage.ListSessions
|
20 | | PipelineStage.Lookup
|
21 | | PipelineStage.Match
|
22 | | PipelineStage.Merge
|
23 | | PipelineStage.Out
|
24 | | PipelineStage.PlanCacheStats
|
25 | | PipelineStage.Project
|
26 | | PipelineStage.Redact
|
27 | | PipelineStage.ReplaceRoot
|
28 | | PipelineStage.ReplaceWith
|
29 | | PipelineStage.Sample
|
30 | | PipelineStage.Search
|
31 | | PipelineStage.SearchMeta
|
32 | | PipelineStage.Set
|
33 | | PipelineStage.SetWindowFields
|
34 | | PipelineStage.Skip
|
35 | | PipelineStage.Sort
|
36 | | PipelineStage.SortByCount
|
37 | | PipelineStage.UnionWith
|
38 | | PipelineStage.Unset
|
39 | | PipelineStage.Unwind
|
40 | | PipelineStage.VectorSearch;
|
41 |
|
42 | export namespace PipelineStage {
|
43 | export interface AddFields {
|
44 |
|
45 | $addFields: Record<string, AnyExpression>
|
46 | }
|
47 |
|
48 | export interface Bucket {
|
49 |
|
50 | $bucket: {
|
51 | groupBy: Expression;
|
52 | boundaries: any[];
|
53 | default?: any
|
54 | output?: Record<string, AccumulatorOperator>
|
55 | }
|
56 | }
|
57 |
|
58 | export interface BucketAuto {
|
59 |
|
60 | $bucketAuto: {
|
61 | groupBy: Expression | Record<string, Expression>;
|
62 | buckets: number;
|
63 | output?: Record<string, AccumulatorOperator>;
|
64 | granularity?: 'R5' | 'R10' | 'R20' | 'R40' | 'R80' | '1-2-5' | 'E6' | 'E12' | 'E24' | 'E48' | 'E96' | 'E192' | 'POWERSOF2';
|
65 | }
|
66 | }
|
67 |
|
68 | export interface CollStats {
|
69 |
|
70 | $collStats: {
|
71 | latencyStats?: { histograms?: boolean };
|
72 | storageStats?: { scale?: number };
|
73 | count?: Record<string | number | symbol, never>;
|
74 | queryExecStats?: Record<string | number | symbol, never>;
|
75 | }
|
76 | }
|
77 |
|
78 | export interface Count {
|
79 |
|
80 | $count: string;
|
81 | }
|
82 |
|
83 | export interface Densify{
|
84 |
|
85 | $densify: {
|
86 | field: string,
|
87 | partitionByFields?: string[],
|
88 | range: {
|
89 | step: number,
|
90 | unit?: 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year',
|
91 | bounds: number[] | globalThis.Date[] | 'full' | 'partition'
|
92 | }
|
93 | }
|
94 | }
|
95 |
|
96 | export interface Fill {
|
97 |
|
98 | $fill: {
|
99 | partitionBy?: Expression,
|
100 | partitionByFields?: string[],
|
101 | sortBy?: Record<string, 1 | -1>,
|
102 | output: Record<string, { value: Expression } | { method: 'linear' | 'locf' }>
|
103 | }
|
104 | }
|
105 |
|
106 | export interface Facet {
|
107 |
|
108 | $facet: Record<string, FacetPipelineStage[]>;
|
109 | }
|
110 |
|
111 | export type FacetPipelineStage = Exclude<PipelineStage, PipelineStage.CollStats | PipelineStage.Facet | PipelineStage.GeoNear | PipelineStage.IndexStats | PipelineStage.Out | PipelineStage.Merge | PipelineStage.PlanCacheStats>;
|
112 |
|
113 | export interface GeoNear {
|
114 |
|
115 | $geoNear: {
|
116 | near: { type: 'Point'; coordinates: [number, number] } | [number, number];
|
117 | distanceField: string;
|
118 | distanceMultiplier?: number;
|
119 | includeLocs?: string;
|
120 | key?: string;
|
121 | maxDistance?: number;
|
122 | minDistance?: number;
|
123 | query?: AnyObject;
|
124 | spherical?: boolean;
|
125 | |
126 |
|
127 |
|
128 |
|
129 | num?: number;
|
130 | }
|
131 | }
|
132 |
|
133 | export interface GraphLookup {
|
134 |
|
135 | $graphLookup: {
|
136 | from: string;
|
137 | startWith: any
|
138 | connectFromField: string;
|
139 | connectToField: string;
|
140 | as: string;
|
141 | maxDepth?: number;
|
142 | depthField?: string;
|
143 | restrictSearchWithMatch?: AnyObject;
|
144 | }
|
145 | }
|
146 |
|
147 | export interface Group {
|
148 |
|
149 | $group: { _id: any } | { [key: string]: AccumulatorOperator }
|
150 | }
|
151 |
|
152 | export interface IndexStats {
|
153 |
|
154 | $indexStats: Record<string | number | symbol, never>;
|
155 | }
|
156 |
|
157 | export interface Limit {
|
158 |
|
159 | $limit: number
|
160 | }
|
161 |
|
162 | export interface ListSessions {
|
163 |
|
164 | $listSessions: { users?: { user: string; db: string }[] } | { allUsers?: true }
|
165 | }
|
166 |
|
167 | export interface Lookup {
|
168 |
|
169 | $lookup: {
|
170 | from: string
|
171 | as: string
|
172 | localField?: string
|
173 | foreignField?: string
|
174 | let?: Record<string, any>
|
175 | pipeline?: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[]
|
176 | }
|
177 | }
|
178 |
|
179 | export interface Match {
|
180 |
|
181 | $match: FilterQuery<any>;
|
182 | }
|
183 |
|
184 | export interface Merge {
|
185 |
|
186 | $merge: {
|
187 | into: string | { db: string; coll: string }
|
188 | on?: string | string[]
|
189 | let?: Record<string, Expression>
|
190 | whenMatched?: 'replace' | 'keepExisting' | 'merge' | 'fail' | Extract<PipelineStage, PipelineStage.AddFields | PipelineStage.Set | PipelineStage.Project | PipelineStage.Unset | PipelineStage.ReplaceRoot | PipelineStage.ReplaceWith>[]
|
191 | whenNotMatched?: 'insert' | 'discard' | 'fail'
|
192 | }
|
193 | }
|
194 |
|
195 | export interface Out {
|
196 |
|
197 | $out: string | { db: string; coll: string }
|
198 | }
|
199 |
|
200 | export interface PlanCacheStats {
|
201 |
|
202 | $planCacheStats: Record<string | number | symbol, never>
|
203 | }
|
204 |
|
205 | export interface Project {
|
206 |
|
207 | $project: { [field: string]: AnyExpression | Expression | Project['$project'] }
|
208 | }
|
209 |
|
210 | export interface Redact {
|
211 |
|
212 | $redact: Expression;
|
213 | }
|
214 |
|
215 | export interface ReplaceRoot {
|
216 |
|
217 | $replaceRoot: { newRoot: AnyExpression }
|
218 | }
|
219 |
|
220 | export interface ReplaceWith {
|
221 |
|
222 | $replaceWith: ObjectExpressionOperator | { [field: string]: Expression } | `$${string}`;
|
223 | }
|
224 |
|
225 | export interface Sample {
|
226 |
|
227 | $sample: { size: number }
|
228 | }
|
229 |
|
230 | export interface Search {
|
231 |
|
232 | $search: {
|
233 | index?: string;
|
234 | highlight?: {
|
235 |
|
236 | path: string | string[] | { value: string, multi: string };
|
237 | maxCharsToExamine?: number;
|
238 | maxNumPassages?: number;
|
239 | };
|
240 | [operator: string]: any;
|
241 | }
|
242 | }
|
243 |
|
244 | export interface SearchMeta {
|
245 |
|
246 | $searchMeta: {
|
247 | index?: string;
|
248 | highlight?: {
|
249 |
|
250 | path: string | string[] | { value: string, multi: string };
|
251 | maxCharsToExamine?: number;
|
252 | maxNumPassages?: number;
|
253 | };
|
254 | [operator: string]: any;
|
255 | }
|
256 | }
|
257 |
|
258 | export interface Set {
|
259 |
|
260 | $set: Record<string, AnyExpression | any>
|
261 | }
|
262 |
|
263 | export interface SetWindowFields {
|
264 |
|
265 | $setWindowFields: {
|
266 | partitionBy?: any
|
267 | sortBy?: Record<string, 1 | -1>
|
268 | output: Record<
|
269 | string,
|
270 | WindowOperator & {
|
271 | window?: {
|
272 | documents?: [string | number, string | number]
|
273 | range?: [string | number, string | number]
|
274 | unit?: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'
|
275 | }
|
276 | }
|
277 | >
|
278 | }
|
279 | }
|
280 |
|
281 | export interface Skip {
|
282 |
|
283 | $skip: number
|
284 | }
|
285 |
|
286 | export interface Sort {
|
287 |
|
288 | $sort: Record<string, 1 | -1 | Expression.Meta>
|
289 | }
|
290 |
|
291 | export interface SortByCount {
|
292 |
|
293 | $sortByCount: Expression;
|
294 | }
|
295 |
|
296 | export interface UnionWith {
|
297 |
|
298 | $unionWith:
|
299 | | string
|
300 | | { coll: string; pipeline?: Exclude<PipelineStage, PipelineStage.Out | PipelineStage.Merge>[] }
|
301 | }
|
302 |
|
303 | export interface Unset {
|
304 |
|
305 | $unset: string | string[]
|
306 | }
|
307 |
|
308 | export interface Unwind {
|
309 |
|
310 | $unwind: string | { path: string; includeArrayIndex?: string; preserveNullAndEmptyArrays?: boolean }
|
311 | }
|
312 | export interface VectorSearch {
|
313 |
|
314 | $vectorSearch: {
|
315 | index: string,
|
316 | path: string,
|
317 | queryVector: number[],
|
318 | numCandidates: number,
|
319 | limit: number,
|
320 | filter?: Expression,
|
321 | }
|
322 | }
|
323 |
|
324 | }
|
325 | }
|