2.0.6 • Published 8 months ago

@nestjs-kitchen/connextion-presto v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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

8 months ago

2.0.5

8 months ago

2.0.4

9 months ago

2.0.3

9 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.3

9 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago