Skip to content

Commit cc1b772

Browse files
committed
feat(tmongodbplugin): add schema registration
1 parent 0511264 commit cc1b772

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

sources/mongodb/TMongoDBPlugin.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
2727
this._schemas = value
2828
}
2929

30+
addSchema( value ) {
31+
this._schemas.push(value)
32+
}
33+
3034
get types () {
3135
return this._types
3236
}
@@ -144,10 +148,13 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
144148
}
145149

146150
beforeRegisterRoutes ( Mongoose ) {
151+
147152
super.beforeRegisterRoutes( Mongoose )
148153

149154
this._registerTypes( Mongoose )
150155
TMongoDBPlugin._registerTypesTo( Mongoose, this.__dirname )
156+
157+
this._registerSchemas( Mongoose )
151158
TMongoDBPlugin._registerSchemasTo( Mongoose, this.__dirname )
152159

153160
}
@@ -163,6 +170,17 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
163170

164171
}
165172

173+
_registerSchemas ( Mongoose ) {
174+
175+
for ( let schema of this._schemas ) {
176+
177+
console.log( `Register schema: ${schema.name}` )
178+
schema( Mongoose )
179+
180+
}
181+
182+
}
183+
166184
}
167185

168186
export { TMongoDBPlugin }

0 commit comments

Comments
 (0)