-
Notifications
You must be signed in to change notification settings - Fork 1
Plugins
Radosław Mejer edited this page May 9, 2020
·
1 revision
The plugin is a function that is called when a new model is created. It should be used to "extend" the model with the desired functionality.
Plugins are set when creating instance of Kex
:
const { Kex } = require('@baethon/kex')
const kex = new Kex({
knex,
plugins: [
require('example-kex-plugin'),
]
})
module.exports = (Model) => {
const { options } = Model
if (!options.enableX) {
return
}
Model.addScope('x', qb => {
qb.where('has_x_factor', true)
})
}
Kex has some built-in plugins, which are used to add new features. Feel free to explore them :)