1 | declare module 'mongoose' {
|
2 | import Kareem = require('kareem');
|
3 |
|
4 | type MongooseQueryAndDocumentMiddleware = 'updateOne' | 'deleteOne';
|
5 |
|
6 | type MongooseDistinctDocumentMiddleware = 'save' | 'init' | 'validate';
|
7 | type MongooseDocumentMiddleware = MongooseDistinctDocumentMiddleware | MongooseQueryAndDocumentMiddleware;
|
8 |
|
9 | type MongooseRawResultQueryMiddleware = 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete';
|
10 | type MongooseDistinctQueryMiddleware = 'estimatedDocumentCount' | 'countDocuments' | 'deleteMany' | 'distinct' | 'find' | 'findOne' | 'findOneAndDelete' | 'findOneAndReplace' | 'findOneAndUpdate' | 'replaceOne' | 'updateMany';
|
11 |
|
12 | type MongooseDefaultQueryMiddleware = MongooseDistinctQueryMiddleware | 'updateOne' | 'deleteOne';
|
13 | type MongooseQueryMiddleware = MongooseDistinctQueryMiddleware | MongooseQueryAndDocumentMiddleware;
|
14 |
|
15 | type MongooseQueryOrDocumentMiddleware = MongooseDistinctQueryMiddleware|MongooseDistinctDocumentMiddleware|MongooseQueryAndDocumentMiddleware;
|
16 |
|
17 | type MiddlewareOptions = {
|
18 | |
19 |
|
20 |
|
21 |
|
22 | document?: boolean,
|
23 | |
24 |
|
25 |
|
26 |
|
27 | query?: boolean,
|
28 | |
29 |
|
30 |
|
31 |
|
32 | errorHandler?: boolean
|
33 | };
|
34 | type SchemaPreOptions = MiddlewareOptions;
|
35 | type SchemaPostOptions = MiddlewareOptions;
|
36 |
|
37 | type PreMiddlewareFunction<ThisType = any> = (
|
38 | this: ThisType,
|
39 | next: CallbackWithoutResultAndOptionalError,
|
40 | opts?: Record<string, any>
|
41 | ) => void | Promise<void> | Kareem.SkipWrappedFunction;
|
42 | type PreSaveMiddlewareFunction<ThisType = any> = (
|
43 | this: ThisType,
|
44 | next: CallbackWithoutResultAndOptionalError,
|
45 | opts: SaveOptions
|
46 | ) => void | Promise<void> | Kareem.SkipWrappedFunction;
|
47 | type PostMiddlewareFunction<ThisType = any, ResType = any> = (this: ThisType, res: ResType, next: CallbackWithoutResultAndOptionalError) => void | Promise<void> | Kareem.OverwriteMiddlewareResult;
|
48 | type ErrorHandlingMiddlewareFunction<ThisType = any, ResType = any> = (this: ThisType, err: NativeError, res: ResType, next: CallbackWithoutResultAndOptionalError) => void;
|
49 | type ErrorHandlingMiddlewareWithOption<ThisType = any, ResType = any> = (this: ThisType, err: NativeError, res: ResType | null, next: CallbackWithoutResultAndOptionalError) => void | Promise<void> | Kareem.OverwriteMiddlewareResult;
|
50 | }
|