Registry / database / surrealdb-orm

surrealdb-orm

JSON →
library1.8.9jsnpmunverified

Typed ORM for SurrealDB with validation, caching, security, and monitoring. Version 1.8.9, active development, updated frequently. Key differentiators: multi-level caching (Memory, Redis), connection pooling, migration system, SQL injection protection, audit logging, and performance metrics. Supports live queries, graph relations, SEARCH indexes, and nested field operations. Peer dependency on TypeScript >=5.0.

npm install surrealdb-orm
INSTALL
IMPORT
SIG · SURREALDB-ORM
S
surrealdb-orm
databasejavascriptv1.8.9
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.

createORM
import { createORM } from 'surrealdb-orm'
const { createORM } = require('surrealdb-orm')
ESM-only package. CommonJS require() will error.
DatabaseSchema
import type { DatabaseSchema } from 'surrealdb-orm/types'
import { DatabaseSchema } from 'surrealdb-orm'
Type-only import from 'surrealdb-orm/types' to avoid runtime overhead.
createEnhancedORM
import { createEnhancedORM } from 'surrealdb-orm/enhanced'
import { createEnhancedORM } from 'surrealdb-orm'
Enhanced ORM is located in a subpath export 'enhanced'.
CacheManager
import { CacheManager } from 'surrealdb-orm/cache'
import { CacheManager } from 'surrealdb-orm'
Cache classes are in the 'cache' subpath export.
MigrationManager
import { MigrationManager } from 'surrealdb-orm/migrations'
import { MigrationManager } from 'surrealdb-orm'
Migration module is in the 'migrations' subpath export.

Defines a schema, connects to SurrealDB, syncs schema, and creates a user via enhanced ORM.

import { DatabaseSchema } from 'surrealdb-orm/types'; import { ConnectionManager, SimpleLogger, SimpleFuture, createEnhancedORM } from 'surrealdb-orm/enhanced'; const schema: DatabaseSchema = { users: { fields: { email: { type: 'string', required: true }, nickname: { type: 'string', required: true }, age: { type: 'number', required: false }, }, indexes: [{ name: 'idx_email', fields: ['email'], unique: true }], }, }; const connection = new ConnectionManager( { rpc: process.env.SURREAL_RPC ?? 'ws://localhost:8000/rpc', namespace: process.env.SURREAL_NS ?? 'test', database: process.env.SURREAL_DB ?? 'test_db', user: process.env.SURREAL_USER ?? 'root', pass: process.env.SURREAL_PASS ?? 'root', }, new SimpleLogger(), new SimpleFuture() ); await connection.connect(); const orm = createEnhancedORM(connection, schema); await orm.syncSchema(); const newUser = await orm.create('users', { email: 'test@example.com', nickname: 'testuser', age: 30 }); console.log('User created:', newUser); await connection.disconnect();
Debug
Known issues
breakingPackage is ESM-only. Using require() will fail.
fix
Use 'import' statements. Set 'type': 'module' in package.json or use .mjs extension.
affects: >=1.0.0
gotchaType imports must use 'import type' from subpath exports like 'surrealdb-orm/types'. Importing from the main export may include runtime code.
fix
Use 'import type { DatabaseSchema } from 'surrealdb-orm/types''.
affects: >=1.0.0
gotchaEnhanced ORM functions (e.g., createEnhancedORM) are in subpath 'surrealdb-orm/enhanced', not in the main entry.
fix
Import from 'surrealdb-orm/enhanced'.
affects: >=1.0.0
breakingNode.js <18 is not supported.
fix
Upgrade Node.js to version >=18.0.0.
affects: >=1.0.0
deprecatedOlder versions used CommonJS exports; v1 switched to ESM.
fix
Migrate to ESM imports as shown above.
affects: <1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Using require() on an ESM-only package.
fix
Replace require() with import statements and ensure package.json has 'type': 'module'.
Cannot find module 'surrealdb-orm/enhanced'
Importing from a subpath export that requires Node >=12 and module resolution set to 'node'.
fix
Ensure tsconfig.json has 'moduleResolution' set to 'node' and Node version >=12.
TypeError: Class extends value undefined is not a constructor or null
Circular dependency or incorrect import path in older versions.
fix
Use exact import paths as documented: e.g., 'surrealdb-orm/types' for types.
Upgrade
Version history
1.8.9latest on npm
Audit
Dependencies
typescriptoptionalPeer dependency required for type definitions and compilation.
Agent activity
18 hits · last 30 days
node
14
Meta
1
Amazon
1
OpenAI (training)
1
Resources
surrealdb-orm — npm install surrealdb-orm · libregistry