mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Merge pull request #9794 from frogcjn/master
Mongoose - improve Schema type information
This commit is contained in:
@@ -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) {});
|
||||
|
||||
Vendored
+35
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user