Registry / database / chouse-orm

chouse-orm

JSON →
library1.0.8jsnpmunverified

A Sequelize-like ORM for ClickHouse database, version 1.0.8, with TypeScript support, connection management, model definitions, fluent query builder, and relationship handling (hasMany, belongsTo, hasOne). Built specifically for ClickHouse's columnar architecture. Released as an npm package with no major release cadence yet. Key differentiators: familiar Sequelize-like API tailored for ClickHouse, supports automatic table creation and migrations, and optimized for ClickHouse performance.

npm install chouse-orm
INSTALL
IMPORT
SIG · CHOUSE-ORM
C
chouse-orm
databasejavascriptv1.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ClickHouseORM (default)
const ClickHouseORM = require('chouse-orm');
import ClickHouseORM from 'chouse-orm';
Package uses CommonJS; ESM import may not work without transpilation.
DataTypes
const { DataTypes } = require('chouse-orm');
import { DataTypes } from 'chouse-orm';
DataTypes is available from the ORM instance or can be imported directly? Actually it's `orm.DataTypes`, not from the package root.
QueryBuilder
const qb = orm.createQueryBuilder();
const { QueryBuilder } = require('chouse-orm');
QueryBuilder is not an exported class but created via orm methods.

Initializes ORM, defines a model with ClickHouse engine, synces table, creates and queries records.

const ClickHouseORM = require('chouse-orm'); const orm = new ClickHouseORM({ host: process.env.CLICKHOUSE_HOST || 'localhost', port: process.env.CLICKHOUSE_PORT || 8123, username: process.env.CLICKHOUSE_USER || 'default', password: process.env.CLICKHOUSE_PASSWORD || '', database: process.env.CLICKHOUSE_DB || 'default' }); async function main() { await orm.authenticate(); console.log('Connected!'); const User = orm.define('User', { id: { type: orm.DataTypes.UInt32, primaryKey: true }, name: orm.DataTypes.String, age: orm.DataTypes.UInt8 }, { engine: 'MergeTree()', orderBy: 'id' }); await orm.sync(); await User.create({ name: 'Alice', age: 30 }); const users = await User.findAll(); console.log(users); } main().catch(console.error);
Debug
Known issues
gotchaRequires @clickhouse/client as a peer dependency and must be installed separately.
fix
Install both packages: npm install chouse-orm @clickhouse/client
affects: >=1.0.0
gotchaESM imports may not work; package uses CommonJS (require).
fix
Use require() instead of import, or use a bundler that handles CJS.
affects: >=1.0.0
gotchaDataTypes are accessed via orm.DataTypes, not directly imported from package.
fix
Use orm.DataTypes after instantiating ORM, e.g., orm.define('Model', { field: { type: orm.DataTypes.String } })
affects: >=1.0.0
gotchaClickHouse does not support UPDATE or DELETE by default; operations only available via ALTER table or specific engine. This ORM may not implement them.
fix
Use recreate or insert operations instead; check documentation for upserts.
affects: >=1.0.0
gotchaTable engine must be specified in model options; default may not be set.
fix
Always include engine and orderBy in model options, e.g., { engine: 'MergeTree()', orderBy: 'id' }
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '@clickhouse/client'
Missing peer dependency @clickhouse/client
fix
npm install @clickhouse/client
TypeError: Cannot read properties of undefined (reading 'UInt32')
DataTypes accessed incorrectly (e.g., import { DataTypes } from 'chouse-orm')
fix
Access DataTypes via the ORM instance: const orm = new ClickHouseORM(...); then orm.DataTypes.UInt32
Error: orm.authenticate is not a function
Using wrong import/initialization or missing await
fix
Ensure you instantiate ORM correctly and call orm.authenticate() as an async function.
Error: Table engine not specified
Missing engine or orderBy in model definition
fix
Add engine and orderBy options: orm.define('Model', {...}, { engine: 'MergeTree()', orderBy: 'id' })
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies
@clickhouse/clientrequiredRequired peer dependency for ClickHouse connectivity
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
chouse-orm — npm install chouse-orm · libregistry