Merge pull request #9794 from frogcjn/master

Mongoose - improve Schema type information
This commit is contained in:
Mohamed Hegazy
2016-06-23 20:25:33 -07:00
committed by GitHub
2 changed files with 36 additions and 3 deletions
+1 -1
View File
@@ -369,7 +369,7 @@ schema.path('name');
schema.path('name', Number);
schema.pathType('name');
schema.plugin(function() {});
schema.post('save', function(doc: IActor) {});
schema.post('save', function(next: () => void, doc: IActor) {});
schema.pre('save', function(next: () => void) {});
schema.requiredPaths();
schema.static('findByName', function(name: string, callback: () => void) {});
+35 -2
View File
@@ -256,6 +256,10 @@ declare module "mongoose" {
OId: Types.ObjectId;
Mixed: any;
};
methods: any;
statics: any;
constructor(schema?: Object, options?: Object);
add(obj: Object, prefix?: string): void;
@@ -269,14 +273,43 @@ declare module "mongoose" {
path(path: string, constructor: any): Schema;
pathType(path: string): string;
plugin(plugin: (schema: Schema, options?: Object) => void, options?: Object): Schema;
post(method: string, fn: Function): Schema;
pre(method: string, callback: Function): Schema;
pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema;
pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema;
post(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema;
post(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema;
requiredPaths(): string[];
set(key: string, value: any): void;
static(name: string, fn: Function): Schema;
virtual(name: string, options?: Object): VirtualType;
virtualpath(name: string): VirtualType;
}
// hook functions: https://github.com/vkarpov15/hooks-fixed
export interface HookSyncCallback {
(next: HookNextFunction, ...hookArgs:any[]): any;
}
export interface HookAsyncCallback {
(next: HookNextFunction, done: HookDoneFunction, ...hookArgs:any[]): any;
}
export interface HookErrorCallback {
(error: Error): any;
}
export interface HookNextFunction {
(error: Error): any;
(...hookArgs:any[]): any;
}
export interface HookDoneFunction {
(error: Error): any;
(...hookArgs:any[]): any;
}
export interface SchemaOption {
autoIndex?: boolean;
bufferCommands?: boolean;