mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #26929 from mjomble/mongodb-aggregate
mongodb: improved overloads for Collection.aggregate()
This commit is contained in:
Vendored
+2
-1
@@ -482,8 +482,9 @@ export interface Collection<TSchema = Default> {
|
||||
// Get current index hint for collection.
|
||||
hint: any;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */
|
||||
aggregate<T = TSchema>(callback: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
||||
aggregate<T = TSchema>(pipeline: Object[], callback: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
||||
aggregate<T = TSchema>(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
||||
aggregate<T = TSchema>(pipeline?: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
||||
/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#bulkWrite */
|
||||
bulkWrite(operations: Object[], callback: MongoCallback<BulkWriteOpResultObject>): void;
|
||||
bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise<BulkWriteOpResultObject>;
|
||||
|
||||
@@ -121,6 +121,31 @@ MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function (err: mo
|
||||
let payment: { total: number };
|
||||
type payment = typeof payment;
|
||||
let cursor: mongodb.AggregationCursor<payment> = collection.aggregate<payment>([{}])
|
||||
|
||||
collection.aggregate([{ $match: { bar: 1 } }, { $limit: 10 }])
|
||||
collection.aggregate([{ $match: { bar: 1 } }]).limit(10)
|
||||
collection.aggregate([]).match({ bar: 1 }).limit(10)
|
||||
collection.aggregate().match({ bar: 1 }).limit(10)
|
||||
|
||||
collection.aggregate<payment>(
|
||||
[{ $match: { bar: 1 } }],
|
||||
function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor<payment>) {
|
||||
cursor.limit(10)
|
||||
}
|
||||
)
|
||||
|
||||
collection.aggregate<payment>(
|
||||
[],
|
||||
function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor<payment>) {
|
||||
cursor.match({ bar: 1 }).limit(10)
|
||||
}
|
||||
)
|
||||
|
||||
collection.aggregate<payment>(
|
||||
function (err: mongodb.MongoError, cursor: mongodb.AggregationCursor<payment>) {
|
||||
cursor.match({ bar: 1 }).limit(10)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// test for new typings
|
||||
|
||||
Reference in New Issue
Block a user