@ark7/model-mongoose
Advanced tools
Comparing version 1.0.20 to 1.0.21
@@ -27,3 +27,3 @@ import * as mongoose from 'mongoose'; | ||
getMongooseOptions(model: string | ModelClass<any>): MongooseOptions; | ||
mapPropertyType(type: runtime.Type): any; | ||
mapPropertyType(type: runtime.Type): MongooseType; | ||
} | ||
@@ -45,2 +45,10 @@ export declare const mongooseManager: MongooseManager; | ||
} | ||
export interface MongooseType { | ||
type: any; | ||
default?: any; | ||
trim?: boolean; | ||
of?: any; | ||
ref?: any; | ||
enum?: (number | string)[]; | ||
} | ||
/** | ||
@@ -56,3 +64,3 @@ * Mongoose options for current model. | ||
}; | ||
mongooseSchema?: mongoose.Schema | object; | ||
mongooseSchema?: mongoose.Schema | MongooseType; | ||
pres: Pre[]; | ||
@@ -59,0 +67,0 @@ posts: Post[]; |
@@ -355,10 +355,10 @@ "use strict"; | ||
const type = manager.mapPropertyType(field.prop.type); | ||
underscore_1.default.defaults(target, options.schema[prop.name], underscore_1.default.isObject(type) && !underscore_1.default.isFunction(type) && type.type != null | ||
? underscore_1.default.extend(type, { | ||
required: !prop.optional, | ||
}) | ||
: { | ||
type, | ||
required: !prop.optional, | ||
}); | ||
if (type.type instanceof mongoose.Schema && | ||
!field.prop.optional && | ||
type.default == null) { | ||
type.default = () => ({}); | ||
} | ||
underscore_1.default.defaults(target, options.schema[prop.name], underscore_1.default.extend(type, { | ||
required: !prop.optional, | ||
})); | ||
} | ||
@@ -365,0 +365,0 @@ } |
{ | ||
"name": "@ark7/model-mongoose", | ||
"version": "1.0.20", | ||
"version": "1.0.21", | ||
"description": "Type-script friendly, object-oriented, database modeling framework", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165930
2341