Skip to content

Commit

Permalink
Updated find and findOne
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Jun 6, 2017
1 parent e175887 commit ae4a071
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions types/mongodb/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,13 @@ export interface Collection {
dropIndexes(): Promise<any>;
dropIndexes(callback?: MongoCallback<any>): void;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find
find(query?: Object): Cursor<any>;
find<T>(query?: Object): Cursor<T>;
find<T = Default>(query?: Object): Cursor<T>;
/** @deprecated */
find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor<any>;
find<T = Default>(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor<T>;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
findOne(filter: Object, callback: MongoCallback<any>): void;
findOne(filter: Object, options?: FindOneOptions): Promise<any>;
findOne(filter: Object, options: FindOneOptions, callback: MongoCallback<any>): void;
findOne<T = Default>(filter: Object, callback: MongoCallback<T>): void;
findOne<T = Default>(filter: Object, options?: FindOneOptions): Promise<T>;
findOne<T = Default>(filter: Object, options: FindOneOptions, callback: MongoCallback<T>): void;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
findOneAndDelete(filter: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject>): void;
findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise<FindAndModifyWriteOpResultObject>;
Expand Down
2 changes: 2 additions & 0 deletions types/mongodb/mongodb-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ let options = {
let cursor: mongodb.Cursor<bag> = collection.find<bag>({color: 'black'})
cursor.toArray(function (err,r) { r[0].cost} );
cursor.forEach(function (bag ) { bag.color }, () => {});
collection.findOne({ color: 'white' }).then(() => { })
collection.findOne<bag>({ color: 'white' }).then(b => { b.cost; })
}
{
let payment: {total: number};
Expand Down

0 comments on commit ae4a071

Please sign in to comment.