mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
add error callback for schema.post() fixes #12943
This commit is contained in:
10
mongoose/index.d.ts
vendored
10
mongoose/index.d.ts
vendored
@@ -609,9 +609,13 @@ declare module "mongoose" {
|
||||
* @param method name of the method to hook
|
||||
* @param fn callback
|
||||
*/
|
||||
post<T extends Document>(method: string, fn: (doc: T, next: (err?: NativeError) => void,
|
||||
...otherArgs: any[]) => void): this;
|
||||
post<T extends Document>(method: string, fn: (doc: T) => void, ...args: any[]): this;
|
||||
post<T extends Document>(method: string, fn: (
|
||||
error: mongodb.MongoError, doc: T, next: (err?: NativeError) => void
|
||||
) => void): this;
|
||||
|
||||
post<T extends Document>(method: string, fn: (
|
||||
doc: T, next: (err?: NativeError) => void
|
||||
) => void): this;
|
||||
|
||||
/**
|
||||
* Defines a pre hook for the document.
|
||||
|
||||
@@ -266,8 +266,19 @@ schema.plugin(function (schema, opts) {
|
||||
schema.get('path');
|
||||
opts.hasOwnProperty('');
|
||||
}).plugin(cb, {opts: true});
|
||||
schema.post('post', function (doc) {}).post('post', function (doc, next) {
|
||||
import { Schema, Model, Document, NativeError } from 'mongoose';
|
||||
schema
|
||||
.post('save', function (error, doc, next) {
|
||||
error.stack;
|
||||
doc.model;
|
||||
next.apply;
|
||||
})
|
||||
.post('save', function (doc: mongoose.Document, next: Function) {
|
||||
doc.model;
|
||||
next(new Error());
|
||||
})
|
||||
.post('save', function (doc: mongoose.Document) {
|
||||
doc.model;
|
||||
});
|
||||
schema.queue('m1', [1, 2, 3]).queue('m2', [[]]);
|
||||
schema.remove('path');
|
||||
|
||||
Reference in New Issue
Block a user