-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathreadable.ts
239 lines (226 loc) · 6.34 KB
/
readable.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
import type {
Document,
AggregateOptions,
CountOptions,
CountDocumentsOptions,
DistinctOptions,
EstimatedDocumentCountOptions,
FindOptions,
ListCollectionsOptions,
ListIndexesOptions,
AggregationCursor,
FindCursor,
DbOptions,
ReadPreferenceFromOptions,
ReadPreferenceLike,
} from './all-transport-types';
import type { ChangeStream, ChangeStreamOptions } from './all-transport-types';
/**
* Interface for read operations in the CRUD specification.
*/
export default interface Readable {
/**
* Run an aggregation pipeline.
*
*
* @param {String} database - The database name.
* @param {String} collection - The collection name.
* @param {Array} pipeline - The aggregation pipeline.
* @param {Document} options - The pipeline options.
* @param {DbOptions} dbOptions - The database options
* @returns {Cursor} A cursor.
*/
aggregate(
database: string,
collection: string,
pipeline: Document[],
options?: AggregateOptions,
dbOptions?: DbOptions
): AggregationCursor;
/**
* Run an aggregation pipeline on the DB.
*
* @param {String} database - The database name.
* @param {Array} pipeline - The aggregation pipeline.
* @param {Document} options - The pipeline options.
* @param {Object} dbOptions - Optional options.
*
* @returns {Cursor} A cursor.
*/
aggregateDb(
database: string,
pipeline: Document[],
options?: AggregateOptions,
dbOptions?: DbOptions
): AggregationCursor;
/**
* Returns the count of documents that would match a find() query for the
* collection or view. The db.collection.count() method does not perform the
* find() operation but instead counts and returns the number of results
* that match a query.
*
* @param {String} db - the db name
* @param {String} coll - the collection name
* @param query
* @param options
* @param {DbOptions} dbOptions - The database options
*
* @returns {Promise} A promise of the result.
*/
count(
db: string,
coll: string,
query?: Document,
options?: CountOptions,
dbOptions?: DbOptions
): Promise<number>;
/**
* Get an exact document count from the collection.
*
* @param {String} database - The database name.
* @param {String} collection - The collection name.
* @param {Document} filter - The filter.
* @param {Document} options - The count options.
* @param {DbOptions} dbOptions - The database options
*
* @returns {Promise} A promise of the result.
*/
countDocuments(
database: string,
collection: string,
filter?: Document,
options?: CountDocumentsOptions,
dbOptions?: DbOptions
): Promise<number>;
/**
* Get distinct values for the field.
*
* @param {String} database - The database name.
* @param {String} collection - The collection name.
* @param {String} fieldName - The field name.
* @param {Document} filter - The filter.
* @param {Document} options - The distinct options.
* @param {DbOptions} dbOptions - The database options
*
* @returns {Document}.
*/
distinct(
database: string,
collection: string,
fieldName: string,
filter?: Document,
options?: DistinctOptions,
dbOptions?: DbOptions
): Promise<Document>;
/**
* Get an estimated document count from the collection.
*
* @param {String} database - The database name.
* @param {String} collection - The collection name.
* @param {Document} options - The count options.
* @param {DbOptions} dbOptions - The database options
*
* @returns {Promise} The promise of the result.
*/
estimatedDocumentCount(
database: string,
collection: string,
options?: EstimatedDocumentCountOptions,
dbOptions?: DbOptions
): Promise<number>;
/**
* Find documents in the collection.
*
* @param {String} database - The database name.
* @param {String} collection - The collection name.
* @param {Document} filter - The filter.
* @param {Document} options - The find options.
* @param {DbOptions} dbOptions - The database options
*
* @returns {Promise} The promise of the cursor.
*/
find(
database: string,
collection: string,
filter?: Document,
options?: FindOptions,
dbOptions?: DbOptions
): FindCursor;
/**
* Get currently known topology information.
*/
getTopology?(): any;
/**
* Returns an array that holds a list of documents that identify and
* describe the existing indexes on the collection.
*
* @param {String} database - The db name.
* @param {String} collection - The collection name.
* @param options
* @param {DbOptions} dbOptions - The database options
*
* @return {Promise}
*/
getIndexes(
database: string,
collection: string,
options: ListIndexesOptions,
dbOptions?: DbOptions
): Promise<Document[]>;
/**
* Returns an array of collection infos
*
* @param {String} database - The db name.
* @param {Document} filter - The filter.
* @param {Document} options - The command options.
* @param {DbOptions} dbOptions - The database options
*
* @return {Promise}
*/
listCollections(
database: string,
filter?: Document,
options?: ListCollectionsOptions,
dbOptions?: DbOptions
): Promise<Document[]>;
/**
* Create a ReadPreference object from a set of options
*/
readPreferenceFromOptions(
options?: Omit<ReadPreferenceFromOptions, 'session'>
): ReadPreferenceLike | undefined;
/**
* Start a change stream cursor on either the client, db, or collection.
* @param pipeline
* @param options
* @param db
* @param dbOptions
* @param coll
*/
watch(
pipeline: Document[],
options: ChangeStreamOptions,
dbOptions?: DbOptions,
db?: string,
coll?: string
): ChangeStream<Document>;
/**
* Returns an array of documents that identify and describe the existing
* search indexes on the collection.
*
* @param {String} database - The db name.
* @param {String} collection - The collection name.
* @param {Document} options - The command options.
* @param {DbOptions} dbOptions - The database options
*
* @return {Promise}
*/
getSearchIndexes(
database: string,
collection: string,
indexName?: string,
// TODO(MONGOSH-1471): use ListSearchIndexesOptions once available
options?: Document,
dbOptions?: DbOptions
): Promise<Document[]>;
}