caluxyr

A type-safe query builder for Cassandra.

Usage no npm install needed!

<script type="module">
  import caluxyr from 'https://cdn.skypack.dev/caluxyr';
</script>

README

Caluxyr

version types publish size license

A type-safe query builder for Cassandra.

Installation

This package is a tiny wrapper around the DataStax Node.js Driver.

# cassandra-driver is a required peer-dependency.
npm install caluxyr cassandra-driver

Usage

import { Client } from 'caluxyr'

const db = new Client({
  contactPoints: ['localhost'],
  localDataCenter: 'datacenter1',
  keyspace: 'MyApp',
})

// Example 1: Selects.
const [user] = await db.select<User>('UserByEmail', {
  where: {
    email: 'hello@example.com',
    verified: true,
  },
  filtering: true,
})

// Example 2: Inserts.
await db.insert<User>('User', {
  data: {
    userId: '794278747242106880',
  },
})

// Example 3: Updates.
await db.update<User>('User', {
  data: {
    verified: false,
  },
  where: {
    userId: '794278747242106880',
  },
})

// Example 4: Deletes.
await db.remove<User>('User', {
  where: {
    userId: '794278747242106880',
  },
})