
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A powerful ORM for ClickHouse, heavily inspired by Drizzle ORM.
Glayse is a modern TypeScript ORM for ClickHouse, designed to provide a seamless and efficient way to interact with your ClickHouse database. Built with type safety in mind, Glayse offers:
Install Glayse
pnpm add glayse
Install the Offical ClickhouseJS client libraries.
pnpm add @clickhouse/client
# or for Browsers (Chrome/Firefox), Cloudflare workers
pnpm add @clickhouse/client-web
import { createClient } from "@clickhouse/client"; // @clickhouse/client-web
import { glayse, string, table } from "glayse/orm";
// Define your Tables
const events = table("events", {
id: string("uuid").$defaultFn(() => crypto.randomUUID()),
name: string(),
description: string().nullable().default(null),
});
// Create the schema object
const schema = {
events
}
// Create client and ORM
const client = createClient(connectionConfig); // For configuration options refer to https://clickhouse.com/docs/integrations/javascript#configuration
const ch = glayse(client, { schema });
// Insert data
await ch.events.insertMany([
{
name: "button_click",
description: "Read More",
},
{
name: "scroll",
},
]);
// Query data with filtering
const clickEvents = await ch.events.findMany({
filter: {
name: { equals: "button_click" }
},
sort: "id",
order: "desc",
limit: 10
});
/*
clickEvents = [
{
id: "63c0fddc-7f2e-4563-9356-257b2d6f5fb7"
name: "button_click",
description: "Read More",
},
{
id: "6a8c3221-cd15-4a87-8946-e51b6146bd3c"
name: "scroll",
description: null
},
]
*/
Define your tables using the table function with column definitions:
import { table, string, uint, datetime, chEnum } from "glayse/orm";
const users = table("users", {
id: uint({ size: 64 }),
name: string(),
email: string(),
age: uint({ size: 8 }).nullable(),
status: chEnum(["active", "inactive", "pending"]),
createdAt: datetime({ timezone: "UTC" }),
});
Glayse supports various ClickHouse data types:
import { string, fixedString } from "glayse/orm";
const table1 = table("example", {
// Variable length string
description: string(),
// Fixed length string
code: fixedString({ length: 10 }),
// With identifier (database column name)
fullName: string("full_name"),
});
import { uint, float } from "glayse/orm";
const analytics = table("analytics", {
// Unsigned integers: UInt8, UInt16, UInt32, UInt64, UInt128, UInt256
views: uint({ size: 32 }),
bigNumber: uint({ size: 64 }),
// Floating point: Float32, Float64
rating: float({ size: 32 }),
precision: float({ size: 64 }),
});
import { datetime } from "glayse/orm";
const logs = table("logs", {
timestamp: datetime(),
utcTime: datetime({ timezone: "UTC" }),
localTime: datetime({ timezone: "America/New_York" }),
});
import { chEnum } from "glayse/orm";
const orders = table("orders", {
// Object-based enum with custom values (Recommended)
priority: chEnum("order_priority", {
1: "low",
2: "medium",
3: "high",
4: "urgent"
}),
// With custom integer size
type: chEnum({
1: "online",
0: "offline",
}, { intSize: 16 }),
// Array-based enum (Not Recommended, Due to the way Clickhouse enums work.)
status: chEnum(["pending", "processing", "shipped", "delivered"]),
});
import { ipv6 } from "glayse/orm";
const connections = table("connections", {
clientIp: ipv6(),
});
const users = table("users", {
username: string(), // name: string
name: string().default("New User"), // name: string
bio: string().nullable(), // bio: string | null
});
const posts = table("posts", {
id: string().$defaultFn(() => crypto.randomUUID()),
title: string(),
published: uint({ size: 8 }).default(0), // Uses sql DEFAULT
createdAt: datetime().$defaultFn(() => new Date().toISOString()), // Creates the default at runtime
});
note Raw SQL is not currently supported
await db.users.insertMany([
{
username: "john.d",
name: "John Doe",
bio: null
},
{
username: "jane.s",
bio: "My cool Bio"
// name has a default, so it can be omitted
},
]);
const allUsers = await db.users.findMany();
/*
allUsers = [
{
username: "john.d",
name: "John Doe",
bio: null
},
{
username: "jane.s",
name: "New User"
bio: "My cool Bio"
}
]
*/
Glayse supports powerful filtering with various operators:
// Find users by exact match
const noBioUsers = await db.users.findMany({
filter: {
bio: { equals: null },
},
sort: "name",
limit: 10
});
/*
noBioUsers = {
username: "john.d",
name: "John Doe",
bio: null
},
*/
// Find users with multiple conditions
const hasBioDefaultNameUsers = await db.users.findMany({
filter: {
name: { equals: "New User" },
bio: { not_equals: null },
},
limit: 10
});
/*
hasBioDefaultNameUsers = [{
username: "jane.s",
name: "New User"
bio: "My cool Bio"
}]
*/
// Sort and limit results
const recentUsers = await db.users.findMany({
sort: "createdAt",
order: "desc",
limit: 10,
offset: 0
});
// Paginated results
const page2Users = await db.users.findMany({
limit: 10,
offset: 10, // Skip first 10 records
});
equals - Exact matchnot_equals - Not equalin - Value in arraynot_in - Value not in arraygt - Greater thangte - Greater than or equallt - Less thanlte - Less than or equalbetween - Between two values (inclusive)// String filtering
await db.events.findMany({
filter: {
eventType: { in: ["click", "scroll"] },
description: { not_equals: null }
}
});
// Numeric filtering
await db.analytics.findMany({
filter: {
views: { between: [100, 1000] },
userId: { gt: 0 },
score: { lte: 95.5 }
}
});
// Date/time filtering
await db.logs.findMany({
filter: {
timestamp: {
gte: "2024-01-01T00:00:00Z",
lt: "2024-02-01T00:00:00Z"
}
}
});
Glayse provides full type inference for your schema:
import type { InferInsert, InferSelect } from "glayse/orm"
// TypeScript automatically infers types
type UserInsert = InferInsert<typeof users>; // or type UserInsert = typeof users.$inferInsert
// {
// id?: number;
// name: string;
// email: string;
// age?: number | null;
// status: "active" | "inactive" | "pending";
// createdAt?: string;
// }
type UserSelect = InferSelect<typeof users>; // or type UserSelect = typeof users.$inferSelect
// {
// id: number;
// name: string;
// email: string;
// age: number | null;
// status: "active" | "inactive" | "pending";
// createdAt: string;
// }
const userSchema = {
users: table("users", {
id: uint({ size: 64 }),
name: string(),
}),
profiles: table("user_profiles", {
userId: uint({ size: 64 }),
bio: string().nullable(),
}),
};
const analyticsSchema = {
events: table("events", {
id: string(),
name: string(),
timestamp: datetime(),
}),
};
// Create separate ORM instances
const userDb = glayse(userClient, { schema: userSchema });
const analyticsDb = glayse(analyticsClient, { schema: analyticsSchema });
Glayse is actively being developed. Here are some planned features:
We welcome contributions!
MIT License - see the LICENSE file for details.
FAQs
A powerful ORM for ClickHouse, heavily inspired by Drizzle ORM.
We found that glayse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.