mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #23573 from jendrikw/mongoose-strict-schema-option
mongoose: add 'throw' to the strict option for schemas
This commit is contained in:
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Mongoose 5.0.1
|
||||
// Project: http://mongoosejs.com/
|
||||
// Definitions by: simonxca <https://github.com/simonxca>, horiuchi <https://github.com/horiuchi>, sindrenm <https://github.com/sindrenm>, lukasz-zak <https://github.com/lukasz-zak>, Alorel <https://github.com/Alorel>
|
||||
// Definitions by: simonxca <https://github.com/simonxca>, horiuchi <https://github.com/horiuchi>, sindrenm <https://github.com/sindrenm>, lukasz-zak <https://github.com/lukasz-zak>, Alorel <https://github.com/Alorel>, jendrikw <https://github.com/jendrikw>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -722,7 +722,7 @@ declare module "mongoose" {
|
||||
/** defaults to null */
|
||||
shardKey?: boolean;
|
||||
/** defaults to true */
|
||||
strict?: boolean;
|
||||
strict?: boolean | 'throw';
|
||||
/** no default */
|
||||
toJSON?: DocumentToObjectOptions;
|
||||
/** no default */
|
||||
|
||||
@@ -432,6 +432,8 @@ new mongoose.Schema({
|
||||
}
|
||||
});
|
||||
|
||||
new mongoose.Schema({foo: String}, {strict: 'throw'});
|
||||
|
||||
export default function(schema: mongoose.Schema) {
|
||||
schema.pre('init', function(this: mongoose.Document, next: (err?: Error) => void): void {
|
||||
console.log('success!');
|
||||
|
||||
Reference in New Issue
Block a user