npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cassandraorm-js

v1.0.3

Published

The most advanced ORM for Apache Cassandra and ScyllaDB with native TypeScript support, AI/ML integration, and enterprise-grade features

Readme

CassandraORM JS

npm version License: MIT Node.js CI

Um ORM moderno e otimizado para Apache Cassandra e ScyllaDB com suporte nativo ao TypeScript, recursos ES6+ e capacidades avançadas.

🚀 Recursos

Recursos Principais

  • TypeScript First - Suporte nativo com tipos completos
  • Módulos ES6+ - Sintaxe moderna de import/export
  • Async/Await - API baseada em Promises
  • Auto-Criação - Criação automática de keyspaces e tabelas
  • Validação de Schema - Validação abrangente de dados
  • Constraints Únicos - Previne inserção de dados duplicados

Recursos Avançados

  • Query Builder - API fluente para queries complexas
  • Cache Inteligente - Estratégias de cache LRU/LFU/FIFO
  • Operações em Lote - Bulk writer estilo MongoDB com processamento em lotes
  • Paginação Otimizada - Paginação baseada em token e cursor
  • Hooks & Middleware - Ciclo de vida extensível de operações
  • Monitoramento de Performance - Métricas e observabilidade integradas

📦 Instalação

npm install cassandraorm-js

⚡ Início Rápido

Uso Básico

const { CassandraORM } = require('cassandraorm-js');

const orm = new CassandraORM({
  contactPoints: ['127.0.0.1'],
  localDataCenter: 'datacenter1',
  keyspace: 'meuapp'
});

await orm.connect();

// Definir modelo
const User = orm.model('users', {
  id: 'uuid',
  name: 'text',
  email: 'text',
  createdAt: 'timestamp'
}, {
  key: ['id']
});

await User.createTable();

// Criar usuário
const user = await User.create({
  id: orm.uuid(),
  name: 'João Silva',
  email: '[email protected]',
  createdAt: new Date()
});

Uso Moderno com TypeScript

import { createClient } from 'cassandraorm-js';

const client = createClient({
  clientOptions: {
    contactPoints: ['127.0.0.1'],
    localDataCenter: 'datacenter1',
    keyspace: 'meuapp'
  },
  ormOptions: {
    createKeyspace: true, // Auto-criar keyspace
    migration: 'safe'     // Auto-criar tabelas
  }
});

await client.connect(); // Cria keyspace automaticamente

const User = await client.loadSchema('users', {
  fields: {
    id: 'uuid',
    email: { 
      type: 'text', 
      unique: true,
      validate: {
        required: true,
        isEmail: true
      }
    },
    name: {
      type: 'text',
      validate: {
        required: true,
        minLength: 2
      }
    },
    age: {
      type: 'int',
      validate: {
        min: 0,
        max: 120
      }
    }
  },
  key: ['id']
}); // Cria tabela automaticamente com validação

Query Builder Avançado

import { AdvancedQueryBuilder } from 'cassandraorm-js';

const queryBuilder = new AdvancedQueryBuilder(client.driver, 'users', 'meuapp');

const users = await queryBuilder
  .select(['name', 'email', 'age'])
  .where('status').eq('ativo')
  .and('age').gte(18)
  .and('categoria').in(['premium', 'gold'])
  .orderBy('created_at', 'DESC')
  .limit(50)
  .allowFiltering()
  .execute();

Operações em Lote

import { BulkWriter } from 'cassandraorm-js';

const bulkWriter = new BulkWriter(client.driver, 'meuapp', {
  batchSize: 100,
  skipDuplicates: true
});

bulkWriter
  .insert('users', { id: client.uuid(), name: 'Usuário 1', email: '[email protected]' })
  .insert('users', { id: client.uuid(), name: 'Usuário 2', email: '[email protected]' })
  .update('users', { age: 26 }, { email: '[email protected]' });

const result = await bulkWriter.execute();
console.log(`Inseridos: ${result.inserted}, Atualizados: ${result.updated}`);

Cache Inteligente

import { IntelligentCache, QueryCache } from 'cassandraorm-js';

const cache = new IntelligentCache({
  ttl: 300,        // 5 minutos
  maxSize: 1000,   // Máximo 1000 itens
  strategy: 'lru'  // Least Recently Used
});

const queryCache = new QueryCache({ ttl: 600 });

// Cache de queries automático
const query = 'SELECT * FROM users WHERE status = ?';
const params = ['ativo'];

let result = queryCache.get(query, params);
if (!result) {
  result = await client.execute(query, params);
  queryCache.set(query, params, result.rows);
}

Hooks e Middleware

import { HooksMiddlewareSystem, CommonHooks } from 'cassandraorm-js';

const hooks = new HooksMiddlewareSystem();

// Adicionar timestamps automaticamente
hooks.beforeCreate(CommonHooks.addTimestamps);
hooks.beforeUpdate(CommonHooks.updateTimestamp);

// Adicionar validação
hooks.beforeCreate(CommonHooks.validate(userSchema));

// Adicionar hook personalizado
hooks.beforeCreate(async (data) => {
  if (data.password) {
    data.password = await hashPassword(data.password);
  }
  return data;
});

// Executar com hooks
const result = await hooks.executeOperation(
  'create',
  userData,
  { operation: 'create', tableName: 'users' },
  async () => {
    return await client.execute(
      'INSERT INTO users (id, name, email) VALUES (?, ?, ?)',
      [userData.id, userData.name, userData.email]
    );
  }
);

📚 Documentação

Português

English

🌍 Idiomas

🔄 Migração

CassandraORM JS é compatível com Express-Cassandra, facilitando a migração.

🧪 Testes

# Executar todos os testes
npm test

# Executar testes específicos
npm run test:ci        # Testes CI
npm run test:bun       # Testes Bun
npm run test:bulk      # Operações em lote
npm run test:features  # Recursos avançados

🤝 Contribuindo

Contribuições são bem-vindas! Veja CONTRIBUTING.md para detalhes.

📄 Licença

Licença MIT - veja o arquivo LICENSE para detalhes.

🔗 Links

⭐ Suporte

Se este projeto foi útil para você, por favor dê uma estrela no GitHub!