Registry / database / ydb-orm

ydb-orm

JSON →
library2.6.2jsnpmunverified

A minimal ORM library for YDB database, designed for rapid development of serverless applications. Current stable version is 2.6.2. Released as needed; key features include lightweight data models, automatic migrations, and compatibility with the Fastify web server framework. Differentiates by providing a simple, Promise-based API and built-in schema synchronization.

npm install ydb-orm
INSTALL
IMPORT
SIG · YDB-ORM
Y
ydb-orm
databasejavascriptv2.6.2
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.

Ydb
import { Ydb } from 'ydb-orm'
const Ydb = require('ydb-orm')
ESM import is recommended; CJS require works but may cause issues with TypeScript types.
YdbModel
import { YdbModel } from 'ydb-orm'
import YdbModel from 'ydb-orm'
YdbModel is a named export, not default.
YdbDataType
import { YdbDataType } from 'ydb-orm'
const { YdbDataType } = require('ydb-orm')
CJS destructuring works, but ESM is preferred for tree-shaking.

Shows defining a model with YdbModel and YdbDataType, initializing Ydb with a connection string, creating and saving a record.

import { Ydb, YdbModel, YdbDataType } from 'ydb-orm'; class User extends YdbModel { static schema = { id: YdbDataType.ascii, name: YdbDataType.ascii, }; id: string; name: string; constructor(fields: Partial<{ id: string; name: string }>) { super(fields); this.id = fields.id || ''; this.name = fields.name || ''; } } const connectionString = process.env.YDB_CONNECTION_STRING ?? ''; const db = Ydb.init({ connectionString, models: [User] }); export async function handler() { const user = new User({ name: 'Alice' }); await user.save(); console.log('User saved:', user.id); }
Debug
Known issues
deprecatedThe 'endpoint' and 'database' options in Ydb.init() are deprecated. Use 'connectionString' instead.
fix
Replace 'endpoint' and 'database' with a single 'connectionString'.
affects: >=2.0.0
breakingIn version 2.0.0, the authentication configuration changed. 'credential', 'token', 'meta' replaced old auth methods.
fix
Update authentication options to use 'credential', 'token', or 'meta'.
affects: >=2.0.0
gotchaYdb.init() must be called before any model operations, but only once per process. Calling it again may cause unexpected behavior.
fix
Ensure Ydb.init() is called exactly once at application startup.
affects: all
gotchaWhen using the Fastify plugin (fastify-ydb-orm), do not call Ydb.init() separately; the plugin handles initialization.
fix
Remove explicit Ydb.init() if using fastify-ydb-orm.
affects: all
breakingThe 'sync' option in YdbFastify plugin registration is now required for automatic schema migrations. Without it, no migrations occur.
fix
Set sync: true when registering the plugin if you want automatic schema synchronization.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Ydb is not initialized. Call Ydb.init() first.
Attempting to use Ydb.db or model operations before initializing.
fix
Ensure Ydb.init({...}) is called before any database access.
TypeError: Class extends value undefined is not a constructor or null
YdbModel not imported correctly (e.g., default import instead of named).
fix
Use named import: import { YdbModel } from 'ydb-orm'.
Upgrade
Version history
2.6.2latest on npm
Audit
Dependencies
fastifyoptionalOptional peer dependency for Fastify plugin integration
Agent activity
31 hits · last 30 days
node
26
OpenAI (training)
1
Resources
ydb-orm — npm install ydb-orm · libregistry