mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-26 00:21:41 +08:00
update to 4.7.0, add querycursor.map() and schema.loadClass()
This commit is contained in:
@@ -196,6 +196,18 @@ QCModel.find({}).cursor({}).on('data', function (doc: any) {
|
||||
}).on('error', function (error: any) {
|
||||
throw error;
|
||||
}).close().then(cb).catch(cb);
|
||||
querycursor.map(function (doc) {
|
||||
doc.foo = "bar";
|
||||
return doc;
|
||||
}).on('data', function (doc: any) {
|
||||
console.log(doc.foo);
|
||||
});
|
||||
querycursor.map(function (doc) {
|
||||
doc.foo = "bar";
|
||||
return doc;
|
||||
}).next(function (error, doc) {
|
||||
console.log(doc.foo);
|
||||
});
|
||||
|
||||
/*
|
||||
* section virtualtype.js
|
||||
|
||||
16
mongoose/mongoose.d.ts
vendored
16
mongoose/mongoose.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Mongoose 4.6.8
|
||||
// Type definitions for Mongoose 4.7.0
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: simonxca <https://github.com/simonxca/>, horiuchi <https://github.com/horiuchi/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -496,11 +496,17 @@ declare module "mongoose" {
|
||||
*/
|
||||
eachAsync(fn: (doc: T) => any, callback?: (err: any) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Registers a transform function which subsequently maps documents retrieved
|
||||
* via the streams interface or .next()
|
||||
*/
|
||||
map(fn: (doc: T) => T): this;
|
||||
|
||||
/**
|
||||
* Get the next document from this cursor. Will return null when there are
|
||||
* no documents left.
|
||||
*/
|
||||
next(callback?: (err: any) => void): Promise<any>;
|
||||
next(callback?: (err: any, doc?: T) => void): Promise<any>;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -563,6 +569,12 @@ declare module "mongoose" {
|
||||
/** Compiles indexes from fields and schema-level indexes */
|
||||
indexes(): any[];
|
||||
|
||||
/**
|
||||
* Loads an ES6 class into a schema. Maps setters + getters, static methods, and
|
||||
* instance methods to schema virtuals, statics, and methods.
|
||||
*/
|
||||
loadClass(model: Function): this;
|
||||
|
||||
/**
|
||||
* Adds an instance method to documents constructed from Models compiled from this schema.
|
||||
* If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as methods.
|
||||
|
||||
Reference in New Issue
Block a user