Skip to content

Commit

Permalink
fix(tmongodbplugin): fix schema registration using different registra…
Browse files Browse the repository at this point in the history
…tion possibilities
  • Loading branch information
Itee committed Aug 13, 2019
1 parent cc1b772 commit 57151b6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions sources/mongodb/TMongoDBPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {

_registerTypes ( Mongoose ) {

for ( let typeWrapper of this._types ) {
for ( let type of this._types ) {

console.log( `Register type: ${typeWrapper.name}` )
typeWrapper( Mongoose )
console.log( `Register type: ${type.name}` )
type( Mongoose )

}

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

console.log( `Register schema: ${schema.name}` )
schema( Mongoose )

if ( isFunction( schema ) ) {

console.log( `Direct register local database schema: ${schema}` )
schema( Mongoose )

} else if ( isFunction( schema.registerModelTo ) ) {

console.log( `Register local database schema: ${schema}` )
schema.registerModelTo( Mongoose )

} else {

console.error( `Unable to register local database schema: ${schema}` )

}

}

Expand Down

0 comments on commit 57151b6

Please sign in to comment.