How to use the knex/lib/helpers.resolveClientNameWithAliases 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 adonisjs / adonis-lucid / test / database / query-client.spec.ts View on Github external
test('get advisory lock', async (assert) => {
      const connection = new Connection('primary', getConfig(), getLogger())
      connection.connect()

      const client = new QueryClient('dual', connection)
      const lock = await client.dialect.getAdvisoryLock(1)

      assert.isTrue(lock)
      assert.equal(client.dialect.name, resolveClientNameWithAliases(connection.config.client))

      await client.dialect.releaseAdvisoryLock(1)
      await connection.disconnect()
    })
github adonisjs / adonis-lucid / src / QueryClient / index.ts View on Github external
*
 * Many of the methods returns `any`, since this class is type casted to an interface,
 * it doesn't real matter what are the return types from this class
 */
export class QueryClient implements QueryClientContract {
  private _dialect: DialectContract

  /**
   * Not a transaction client
   */
  public readonly isTransaction = false

  /**
   * The name of the dialect in use
   */
  public dialect = new (dialects[resolveClientNameWithAliases(this._connection.config.client)])(this)

  /**
   * The profiler to be used for profiling queries
   */
  public profiler?: ProfilerRowContract | ProfilerContract

  /**
   * Name of the connection in use
   */
  public readonly connectionName = this._connection.name

  constructor (
    public readonly mode: 'dual' | 'write' | 'read',
    private _connection: ConnectionContract,
  ) {
  }