2.0.6 • Published 8 months ago
@nestjs-kitchen/connextion-presto v2.0.6
@nestjs-kitchen/connextion-presto
A flexible module to provide presto-client interface in NextJS.
Install
$ npm install --save @nestjs-kitchen/connextion @nestjs-kitchen/connextion-presto presto-client @types/presto-clientUsage
Apply PrestoModule
Export module, service & decorator.
export const { Presto, PrestoModule } = definePresto(); export type Presto = InstanceType<typeof Presto>;Register presto connection instance with options.
@Module({ imports: [ // By default it will register a connection instance called `default`. PrestoModule.register({ // default's options... }) ], providers: [SampleService] }) export class SampleModule {}Inject
Prestoservice.import { Presto } from './file-that-exported-presto'; @Injectable() class SampleService { constructor( private readonly presto: Presto, ) {} async sampleMethod() { const result1 = await this.presto.default.execute({ query: `select 1=1;` }); } }
Register multiple presto instances
Define presto connection instance names and export module, service & decorator.
e.g.:
instance_1,instance_2.export const { Presto, PrestoModule } = definePresto<'instance_1' | 'instance_2'>(); export type Presto = InstanceType<typeof Presto>;Register presto connection instances with options.
@Module({ imports: [ PrestoModule.register({ connections: [ { name: 'instance1', // instance_1's options... }, { name: 'instance2', // instance_2's options... } ] }) ], providers: [SampleService] }) export class SampleModule {}Inject
Prestoservice.import { Presto } from './file-that-exported-presto'; @Injectable() class SampleService { constructor( private readonly presto: Presto, ) {} async sampleMethod() { const result1 = await this.presto.instance1.execute({ query: `select 1=1;` }); } }
License
MIT License