Skip to content

Commit

Permalink
fix(tmongodbplugin): change shema registration order. check before re…
Browse files Browse the repository at this point in the history
…gisterModelTo and then function
  • Loading branch information
Itee committed Aug 14, 2019
1 parent 2671099 commit 2161b43
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions sources/mongodb/TMongoDBPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
this._schemas = value
}

addSchema( value ) {
addSchema ( value ) {

this._schemas.push(value)
this._schemas.push( value )
return this

}

get types () {
Expand Down Expand Up @@ -179,15 +179,13 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {

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

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

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

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

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

} else {

Expand Down

0 comments on commit 2161b43

Please sign in to comment.