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