Skip to content

Commit 57151b6

Browse files
committed
fix(tmongodbplugin): fix schema registration using different registration possibilities
1 parent cc1b772 commit 57151b6

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

sources/mongodb/TMongoDBPlugin.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
161161

162162
_registerTypes ( Mongoose ) {
163163

164-
for ( let typeWrapper of this._types ) {
164+
for ( let type of this._types ) {
165165

166-
console.log( `Register type: ${typeWrapper.name}` )
167-
typeWrapper( Mongoose )
166+
console.log( `Register type: ${type.name}` )
167+
type( Mongoose )
168168

169169
}
170170

@@ -175,7 +175,22 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
175175
for ( let schema of this._schemas ) {
176176

177177
console.log( `Register schema: ${schema.name}` )
178-
schema( Mongoose )
178+
179+
if ( isFunction( schema ) ) {
180+
181+
console.log( `Direct register local database schema: ${schema}` )
182+
schema( Mongoose )
183+
184+
} else if ( isFunction( schema.registerModelTo ) ) {
185+
186+
console.log( `Register local database schema: ${schema}` )
187+
schema.registerModelTo( Mongoose )
188+
189+
} else {
190+
191+
console.error( `Unable to register local database schema: ${schema}` )
192+
193+
}
179194

180195
}
181196

0 commit comments

Comments
 (0)