mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
FixType(mongoose): fix minor syntax issues and make options nonNullable in v3
Check ensure by linting
This commit is contained in:
@@ -293,7 +293,7 @@ schema.method('name', cb).method({
|
||||
});
|
||||
schema.path('a', mongoose.Schema.Types.Buffer).path('a');
|
||||
schema.pathType('m1').toLowerCase();
|
||||
schema.plugin(function (schema, opts) {
|
||||
schema.plugin(function (schema: mongoose.Schema, opts?: any) {
|
||||
schema.get('path');
|
||||
if (opts) {
|
||||
opts.hasOwnProperty('');
|
||||
@@ -564,25 +564,25 @@ new mongoose.Schema({
|
||||
}
|
||||
});
|
||||
|
||||
(new mongoose.Schema({})).plugin(function (schema: any, options: any) {
|
||||
(new mongoose.Schema({})).plugin<any>(function (schema: mongoose.Schema, options: any) {
|
||||
schema.add({ lastMod: Date })
|
||||
schema.pre('save', function (next: Function) {
|
||||
this.lastMod = new Date
|
||||
(this as any).lastMod = new Date
|
||||
next()
|
||||
})
|
||||
if (options && options['index']) {
|
||||
schema.path('lastMod').index(options['index'])
|
||||
}
|
||||
}, { index: true }).plugin(function (schema: any, options: any) {
|
||||
}, { index: true }).plugin<any>(function (schema: mongoose.Schema, options: any) {
|
||||
schema.add({ lastMod: Date })
|
||||
schema.pre('save', function (next: Function) {
|
||||
this.lastMod = new Date
|
||||
(this as any).lastMod = new Date
|
||||
next()
|
||||
})
|
||||
if (options && options['index']) {
|
||||
schema.path('lastMod').index(options['index'])
|
||||
}
|
||||
});
|
||||
}, {index: true});
|
||||
|
||||
new mongoose.Schema({foo: String}, {strict: 'throw'});
|
||||
|
||||
@@ -595,7 +595,7 @@ export default function(schema: mongoose.Schema) {
|
||||
// plugins
|
||||
function MyPlugin(schema: mongoose.Schema, opts?: string) {
|
||||
}
|
||||
mongoose.Schema({})
|
||||
new mongoose.Schema({})
|
||||
.plugin(MyPlugin)
|
||||
|
||||
interface PluginOption {
|
||||
|
||||
8
types/mongoose/v3/index.d.ts
vendored
8
types/mongoose/v3/index.d.ts
vendored
@@ -14,8 +14,8 @@ declare module "mongoose" {
|
||||
|
||||
function model<T extends Document>(name: string, schema?: Schema, collection?: string, skipInit?: boolean): Model<T>;
|
||||
function modelNames(): string[];
|
||||
function plugin(plugin: (schema: Schema) => void): Mongoose
|
||||
function plugin<T>(plugin: (schema: Schema, options?: T) => void, options?: T): Mongoose;
|
||||
function plugin(plugin: (schema: Schema) => void): Mongoose;
|
||||
function plugin<T>(plugin: (schema: Schema, options: T) => void, options: T): Mongoose;
|
||||
|
||||
function get(key: string): any;
|
||||
function set(key: string, value: any): void;
|
||||
@@ -35,7 +35,7 @@ declare module "mongoose" {
|
||||
model<T extends Document>(name: string, schema?: Schema, collection?: string, skipInit?: boolean): Model<T>;
|
||||
modelNames(): string[];
|
||||
plugin(plugin: (schema: Schema) => void): Mongoose;
|
||||
plugin<T>(plugin: (schema: Schema, options?: T) => void, options?: T): Mongoose;
|
||||
plugin<T>(plugin: (schema: Schema, options: T) => void, options: T): Mongoose;
|
||||
set(key: string, value: any): void;
|
||||
|
||||
mongo: any;
|
||||
@@ -276,7 +276,7 @@ declare module "mongoose" {
|
||||
path(path: string, constructor: any): Schema;
|
||||
pathType(path: string): string;
|
||||
plugin(plugin: (schema: Schema) => void): Schema;
|
||||
plugin<T>(plugin: (schema: Schema, options?: T) => void, options?: T): Schema;
|
||||
plugin<T>(plugin: (schema: Schema, options: T) => void, options: T): Schema;
|
||||
|
||||
pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema;
|
||||
pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema;
|
||||
|
||||
@@ -262,7 +262,7 @@ schema.method('name', cb).method({
|
||||
});
|
||||
schema.path('a', mongoose.Schema.Types.Buffer).path('a');
|
||||
schema.pathType('m1').toLowerCase();
|
||||
schema.plugin(function (schema, opts) {
|
||||
schema.plugin(function (schema: mongoose.Schema, opts?: any) {
|
||||
schema.get('path');
|
||||
if (opts) {
|
||||
opts.hasOwnProperty('');
|
||||
@@ -424,7 +424,7 @@ new mongoose.Schema({
|
||||
if (options && options['index']) {
|
||||
schema.path('lastMod').index(options['index'])
|
||||
}
|
||||
});
|
||||
}, {index: true});
|
||||
|
||||
// plugins
|
||||
interface PluginOption {
|
||||
|
||||
Reference in New Issue
Block a user