JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 165
  • Score
    100M100P100Q90464F
  • License MIT

Cassandra Nest.js connector module

Package Exports

  • @mich4l/nestjs-cassandra

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mich4l/nestjs-cassandra) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Nest Logo

Nest.js Cassandra module

Cassandra module based on npm library cassandra-driver.

Installation

npm

npm run @mich4l/nestjs-cassandra

Yarn

yarn add @mich4l/nestjs-cassandra

Examples

app.module.ts

import { Module } from '@nestjs/common';
import { CassandraModule } from 'mich4l/nestjs-cassandra';

@Module({
  imports: [
    CassandraModule.register({
      keyspace: 'my_keyspace',
      contactPoints: ['127.0.0.1'],
      localDataCenter: 'datacenter1',
    }),
  controllers: [],
  providers: [],
})
export class AppModule {}

example.service.ts

import { Inject, Injectable } from '@nestjs/common';
import { CASSANDRA_CLIENT } from '@mich4l/nestjs-cassandra';
import { Client } from 'cassandra-driver';

@Injectable()
export class ExampleService {
    constructor(
        @Inject(CASSANDRA_CLIENT)
        private readonly dbClient: Client,
    ) {}

    async getAllPosts() {
        const query = 'SELECT * FROM posts';
        const result = await this.dbClient.execute(query);

        return result.rows[0];
    }
}