import { Plugin, MountData, Next, InvokeData, UseifyPlugin } from '@faasjs/func'; import { Logger } from '@faasjs/logger'; import knex, { Knex as Knex$1 } from 'knex'; export { Knex as OriginKnex } from 'knex'; /** * FaasJS's sql plugin, base on [Knex](https://knexjs.org/). * * [![License: MIT](https://img.shields.io/npm/l/@faasjs/knex.svg)](https://github.com/faasjs/faasjs/blob/main/packages/knex/LICENSE) * [![NPM Version](https://img.shields.io/npm/v/@faasjs/knex.svg)](https://www.npmjs.com/package/@faasjs/knex) * * ## Install * * ```sh * npm install @faasjs/knex * ``` * @packageDocumentation */ /** * Origin [knex](https://knexjs.org/) instance. */ declare const originKnex: typeof knex; type KnexConfig = { name?: string; config?: Knex$1.Config; }; declare class Knex implements Plugin { readonly type = "knex"; readonly name: string; config: Knex$1.Config; adapter: Knex$1; query: Knex$1; logger: Logger; constructor(config?: KnexConfig); onMount(data: MountData, next: Next): Promise; onInvoke(data: InvokeData, next: Next): Promise; raw(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise>; /** * Wraps a transaction, returning a promise that resolves to the return value of the callback. * * - Support 'commit' and 'rollback' event. */ transaction(scope: (trx: Knex$1.Transaction) => Promise, config?: Knex$1.TransactionConfig, options?: { trx?: Knex$1.Transaction; }): Promise; schema(): Knex$1.SchemaBuilder; quit(): Promise; } declare function useKnex(config?: KnexConfig): UseifyPlugin; declare function query(table: TName): Knex$1.QueryBuilder, { _base: Knex$1.ResolveTableType, 'base'>; _hasSelection: false; _keys: never; _aliases: {}; _single: false; _intersectProps: {}; _unionProps: never; }[]>; declare function query(table: string): Knex$1.QueryBuilder; declare function transaction(scope: (trx: Knex$1.Transaction) => Promise, config?: Knex$1.TransactionConfig, options?: { trx?: Knex$1.Transaction; }): Promise; declare function raw(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise>; export { Knex, type KnexConfig, originKnex, query, raw, transaction, useKnex };