Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
})
*
* 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,
) {
}