Registry / database / surqlize

surqlize

JSON →
library0.1.0jsnpmunverified

A type-safe TypeScript ORM for SurrealDB, currently in development at version 0.1.0. It provides a fluent query builder with full type inference via a t.* schema builder, supporting CRUD operations, graph relationships, and SurrealDB functions. Unlike other SurrealDB libraries, it eliminates code generation by inferring types directly from schema definitions. Requires surrealdb.js v2.0.0-alpha.18 and TypeScript 5+. Release cadence is early-stage alpha with frequent breaking changes.

npm install surqlize
INSTALL
IMPORT
SIG · SURQLIZE
S
surqlize
databasejavascriptv0.1.0
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.

orm
import { orm } from 'surqlize'
const { orm } = require('surqlize')
Package is ESM-only. CommonJS require will fail.
table
import { table } from 'surqlize'
import { Table } from 'surqlize'
The function is lowercase 'table' (named export), not a class.
t
import { t } from 'surqlize'
import t from 'surqlize'
t is a named export, not default export.
t.infer
import { t } from 'surqlize' type MyType = t.infer<typeof query>
t.infer is a utility type introduced in v0.1.0 for extracting result types.
t.string
import { t } from 'surqlize' const schema = { name: t.string() }
import { string } from 'surqlize'
t.string is a function on the 't' object, not a standalone export.

Connects to SurrealDB, defines a user schema, builds a type-safe query selecting users over 18, and executes it.

import { Surreal } from 'surrealdb'; import { orm, table, t } from 'surqlize'; const user = table('user', { name: t.string(), email: t.string(), age: t.number(), }); const db = orm(new Surreal(), user); async function main() { await db.connection.connect('http://localhost:8000/rpc', { namespace: 'test', database: 'test', auth: { user: 'root', pass: 'root' }, }); const query = db .select('user') .where((user) => user.age.gte(18)) .return((user) => ({ name: user.name, email: user.email })); console.log(await query); } main();
Debug
Known issues
breakingThis package is in early development (alpha). Expect frequent breaking changes between minor versions.
fix
Pin exact version and review changelog before upgrading.
affects: >=0.1.0 <1.0.0
deprecatedRequires surrealdb v2.0.0-alpha.18 which is itself an alpha release.
fix
Install surrealdb@2.0.0-alpha.18 exactly. Do not use later alpha versions without verifying compatibility.
affects: >=0.1.0
gotchaESM-only package - cannot be used with CommonJS require().
fix
Use ES module imports or dynamic import().
affects: >=0.1.0
gotchat.* schema functions (e.g., t.string()) must be called - they are factory functions, not types.
fix
Always invoke: t.string(), t.number(), etc. Not just t.string.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Attempting to use require() on an ESM-only package.
fix
Convert your project to ESM or use dynamic import: const surqlize = await import('surqlize')
TypeError: t.string is not a function
Accessing t.string without calling it as a function.
fix
Use t.string() instead of t.string
Cannot find module 'surrealdb' or its corresponding type declarations
surrealdb peer dependency not installed.
fix
Run: npm install surrealdb@2.0.0-alpha.18
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
surrealdbrequiredPeer dependency: surqlize wraps the surrealdb client to execute queries.
typescriptrequiredPeer dependency: type inference relies on TypeScript 5+ features.
Agent activity
18 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
surqlize — npm install surqlize · libregistry