How to use the knex.constructor function in knex

To help you get started, we’ve selected a few knex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github garbin / koapi / src / model.es View on Github external
export function initialize(knex_config) {
  if (!bookshelf) {
    bookshelf = Bookshelf(
      knex_config instanceof knex.constructor ?
      knex_config :
      knex(knex_config)
    ).plugin('registry')
     .plugin('virtuals')
     .plugin('visibility')
     .plugin('pagination')
     .plugin(cascade_delete)
     .plugin(soft_delete)
     .plugin(mask)
     .plugin(uuid)
     .plugin(koapi_base_model_plugin)
  }
}
github garbin / koapi / lib / model / index.js View on Github external
connect (knexConfig) {
    if (!internal.connection) {
      internal.connection = knexConfig instanceof knex.constructor
      ? knexConfig
      : knex(knexConfig)
    }
    if (!internal.bookshelf) {
      internal.bookshelf = Bookshelf(internal.connection)
      .plugin('registry')
      .plugin('virtuals')
      .plugin('visibility')
      .plugin('pagination')
      .plugin(modelBase.pluggable)
      .plugin(cascadeDelete)
      .plugin(softDelete)
      .plugin(mask)
      .plugin(uuid)
      .plugin(validate)
      .plugin(formatter)
github garbin / koapi / lib / model.js View on Github external
exports.default = exports.connect = function (knexConfig) {
  if (!internal.connection) {
    internal.connection = knexConfig instanceof knex.constructor
        ? knexConfig
        : knex(knexConfig)
  }
  if (!internal.bookshelf) {
    internal.bookshelf = Bookshelf(internal.connection).plugin('registry')
     .plugin('virtuals')
     .plugin('visibility')
     .plugin('pagination')
     .plugin(jsonColumns)
     .plugin(koapiBaseModel)
     .plugin(cascadeDelete)
     .plugin(softDelete)
     .plugin(mask)
     .plugin(uuid)
  }
  return internal