2.0.6 • Published 9 months ago

@nestjs-kitchen/connextion-presto v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@nestjs-kitchen/connextion-presto

NPM Version NPM License codecov

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-client

Usage

Apply PrestoModule

  1. Export module, service & decorator.

    export const { Presto, PrestoModule } = definePresto();
    export type Presto = InstanceType<typeof Presto>;
  2. 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 {} 
  3. Inject Presto service.

    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

  1. 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>;
  2. 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 {} 
  3. Inject Presto service.

    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

2.0.6

9 months ago

2.0.5

9 months ago

2.0.4

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.3

11 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago