Skip to content

Commit

Permalink
feat(tmongodbplugin): add schema registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Itee committed Aug 13, 2019
1 parent 0511264 commit cc1b772
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sources/mongodb/TMongoDBPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
this._schemas = value
}

addSchema( value ) {
this._schemas.push(value)
}

get types () {
return this._types
}
Expand Down Expand Up @@ -144,10 +148,13 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {
}

beforeRegisterRoutes ( Mongoose ) {

super.beforeRegisterRoutes( Mongoose )

this._registerTypes( Mongoose )
TMongoDBPlugin._registerTypesTo( Mongoose, this.__dirname )

this._registerSchemas( Mongoose )
TMongoDBPlugin._registerSchemasTo( Mongoose, this.__dirname )

}
Expand All @@ -163,6 +170,17 @@ class TMongoDBPlugin extends TAbstractDatabasePlugin {

}

_registerSchemas ( Mongoose ) {

for ( let schema of this._schemas ) {

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

}

}

}

export { TMongoDBPlugin }

0 comments on commit cc1b772

Please sign in to comment.