Update collection to support new crud operations

This commit is contained in:
lnlwd
2015-07-14 22:53:55 -03:00
parent 34b5eb499d
commit 9916fab22d
+56 -5
View File
@@ -296,21 +296,54 @@ declare module "mongodb" {
// Documentation : http://mongodb.github.io/node-mongodb-native/api-generated/collection.html
export interface Collection {
new (db: Db, collectionName: string, pkFactory?: Object, options?: CollectionCreateOptions): Collection; // is this right?
/**
* @deprecated use insertOne or insertMany
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insert
*/
insert(query: any, callback: (err: Error, result: any) => void): void;
insert(query: any, options: { safe?: any; continueOnError?: boolean; keepGoing?: boolean; serializeFunctions?: boolean; }, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertOne
inserOne(doc:any, callback: (err: Error, result: any) => void) :void;
insertOne(doc: any, options: { w?: any; wtimeout?: number; j?: boolean; serializeFunctions?: boolean; forceServerObjectId?: boolean }, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#insertMany
insertMany(docs, callback: (err: Error, result: any) => void): void;
insertMany(docs, options: { w?: any; wtimeout?: number; j?: boolean; serializeFunctions?: boolean; forceServerObjectId?: boolean }, callback: (err: Error, result: any) => void): void;
/**
* @deprecated use deleteOne or deleteMany
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#remove
*/
remove(selector: Object, callback?: (err: Error, result: any) => void): void;
remove(selector: Object, options: { safe?: any; single?: boolean; }, callback?: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteOne
deleteOne(filter, callback: (err: Error, result: any) => void): void;
deleteOne(filter, options: { w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#deleteMany
deleteMany(filter, callback: (err: Error, result: any) => void): void;
deleteMany(filter, options: { w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
rename(newName: String, callback?: (err: Error, result: any) => void): void;
save(doc: any, callback : (err: Error, result: any) => void): void;
save(doc: any, options: { safe: any; }, callback : (err: Error, result: any) => void): void;
save(doc: any, options: { w?: any; wtimeout?: number; j?: boolean;}, callback : (err: Error, result: any) => void): void;
/**
* @deprecated use updateOne or updateMany
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#update
*/
update(selector: Object, document: any, callback?: (err: Error, result: any) => void): void;
update(selector: Object, document: any, options: { safe?: boolean; upsert?: any; multi?: boolean; serializeFunctions?: boolean; }, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateOne
updateOne(filter: Object, update: any, callback: (err: Error, result: any) => void): void;
updateOne(filter: Object, update: any, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#updateMany
updateMany(filter: Object, update: any, callback: (err: Error, result: any) => void): void;
updateMany(filter: Object, update: any, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean;}, callback: (err: Error, result: any) => void): void;
distinct(key: string, query: Object, callback: (err: Error, result: any) => void): void;
distinct(key: string, query: Object, options: { readPreference: string; }, callback: (err: Error, result: any) => void): void;
@@ -319,13 +352,31 @@ declare module "mongodb" {
count(query: Object, options: { readPreference: string; }, callback: (err: Error, result: any) => void): void;
drop(callback?: (err: Error, result: any) => void): void;
/**
* @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify
*/
findAndModify(query: Object, sort: any[], doc: Object, callback: (err: Error, result: any) => void): void;
findAndModify(query: Object, sort: any[], doc: Object, options: { safe?: any; remove?: boolean; upsert?: boolean; new?: boolean; }, callback: (err: Error, result: any) => void): void;
/**
* @deprecated use findOneAndDelete
* Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndRemove
*/
findAndRemove(query : Object, sort? : any[], callback?: (err: Error, result: any) => void): void;
findAndRemove(query : Object, sort? : any[], options?: { safe: any; }, callback?: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndDelete
findOneAndDelete(filter: any, callback: (err: Error, result: any) => void): void;
findOneAndDelete(filter: any, options: { projection?: any; sort?: any; maxTimeMS?: number; }, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndReplace
findOneAndReplace(filter: any, replacement: any, callback: (err: Error, result: any) => void): void;
findOneAndReplace(filter: any, replacement: any, options: { projection?: any; sort?: any; maxTimeMS?: number; upsert?: boolean; returnOriginal?: boolean }, callback: (err: Error, result: any) => void): void;
// Documentation : http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findOneAndUpdate
findOneAndUpdate(filter: any, update: any, callback: (err: Error, result: any) => void): void;
findOneAndUpdate(filter: any, update: any, options: { projection?: any; sort?: any; maxTimeMS?: number; upsert?: boolean; returnOriginal?: boolean }, callback: (err: Error, result: any) => void): void;
find(callback?: (err: Error, result: Cursor) => void): Cursor;
find(selector: Object, callback?: (err: Error, result: Cursor) => void): Cursor;
find(selector: Object, fields: any, callback?: (err: Error, result: Cursor) => void): Cursor;