New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nest-cassandra

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-cassandra

Cassandra utilities module for NestJs.

  • 0.0.5
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Cassandra utilities module for NestJs.

Installation

$ npm install nest-cassandra

Usage

import { CassandraModule } from 'nest-cassandra'
import { auth } from 'cassandra-driver'

@Module({
  imports: [
    CassandraModule.forRoot({
      keyspace: 'test',
      contactPoints: ['127.0.0.1:9042'],
      localDataCenter: 'datacenter1',
      authProvider: new auth.PlainTextAuthProvider('user', 'pass');
    })
  ],
  providers: [...]
})
export class AppModule {}

Model

import { CassandraModel } from 'nest-cassandra'
import { types } from 'cassandra-driver'

export class LookupByHash extends CassandraModel {
  @CassandraPartitioningKey()
  @CassandraColumn(types.dataTypes.blob)
  @CassandraTransforms({
    fromJSON: hexStringToBlob,
    fromCassandra: hexBlobToString,
  })
  hash: string;

  @CassandraClusteringKey()
  @CassandraColumn(types.dataTypes.blob)
  archive: string;

  @CassandraColumn(types.dataTypes.timestamp)
  timestamp: Date;
}

Crud

import { Injectable } from '@nestjs/common';
import { CassandraRepository } from 'nest-cassandra'

export class LookupByHashRepository extends CassandraRepository<LookupByHash> {
  tableName = 'lookup_by_hash';
  modelName = 'LookupByHash';
  model = new LookupByHash();
}

@Injectable()
export class LookupByHashService {
  constructor(
    private readonly boundWitnessesByHashRepository: LookupByHashRepository,
  ) {}

  findByHash(hash: string) {
    return this.boundWitnessesByHashRepository.findOne({ hash });
  }

  page({ limit, cursor, ...query }) {
    return this.boundWitnessesByArchiveRepository.page(query, {
      limit,
      cursor,
    });
  }
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

FAQs

Package last updated on 29 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc