Registry / database / victoria-orm

victoria-orm

JSON →
library0.3.2jsnpmunverified

Drizzle-style typed ORM for VictoriaLogs, version 0.3.2, with schema-first queries, typed inserts, and zero dependencies. Provides a fluent query builder for LogsQL, supporting select, count, group-by, insert, raw queries, and health checks. Ships TypeScript types and supports Basic Auth, Bearer tokens, or no auth. Differentiates from raw LogsQL clients by providing type-safe stream definitions, column types (text, timestamp, enum), and operators (eq, contains, not, exists, regex) with full TypeScript inference. Released as an early-stage package (0.x) on npm.

npm install victoria-orm
INSTALL
IMPORT
SIG · VICTORIA-ORM
V
victoria-orm
databasejavascriptv0.3.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.

victoriaLogs
import { victoriaLogs } from 'victoria-orm'
const victoriaLogs = require('victoria-orm')
ESM-only; requires Node >= 18 and "type": "module" or .mjs extension
stream
import { stream } from 'victoria-orm'
import { table } from 'victoria-orm'
Use stream() (not table()) to define a log stream
eq
import { eq } from 'victoria-orm'
import { equals } from 'victoria-orm'
Operators are eq, not, contains, exists, regex — not equals or like
enm
import { enm } from 'victoria-orm'
const { enm } = require('victoria-orm')
Enum type factory: enm('status', ['a','b']) — not enum (reserved word)
text
import { text } from 'victoria-orm'
Default column type; use text().notNull() for required fields

Initializes a VictoriaLogs client, defines a typed stream schema, queries bounced emails with a subject filter, and logs results.

import { victoriaLogs, stream, text, enm, eq, contains, after } from 'victoria-orm'; const vl = victoriaLogs({ url: process.env.VL_URL ?? 'http://localhost:9428', username: process.env.VL_USER ?? '', password: process.env.VL_PASS ?? '', }); const emails = stream('email-archive', { id: text('id'), to: text('to').notNull(), from: text('from').notNull(), subject: text('subject'), status: enm('status', ['delivered', 'bounced', 'deferred', 'opened', 'clicked']), }); async function main() { const result = await vl.select().from(emails) .where(eq(emails.status, 'bounced')) .where(contains(emails.subject, 'urgent')) .limit(10) .execute(); console.log(result.logs); } main().catch(console.error);
Debug
Known issues
gotchaBasic Auth credentials must be passed as username/password, not Authorization header; victoriaLogs sends Basic Auth automatically when both are provided.
fix
Supply username and password fields in the config object.
affects: >=0.0.1
gotchaAll streams must have at least one column; an empty schema will throw at runtime.
fix
Define at least one column (e.g., text('id')) in the stream definition.
affects: >=0.0.0
gotchaThe after() operator accepts a duration string like '2h' not a Date object; it generates the LogsQL '_time:after(2h)' filter.
fix
Pass a relative time string (e.g., '30m', '1h', '7d') to after().
affects: >=0.0.0
gotchaThe count() method returns a number, not an array; it is a terminal operation that cannot be chained after limit/offset.
fix
Call count() directly on the query builder without preceding limit/offset.
affects: >=0.0.0
gotchaMultiple .where() calls are combined with AND; there is no OR support in the current version.
fix
Use raw queries with explicit LogsQL for OR conditions, or chain .where() with all AND conditions.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: (0 , victoria_orm_1.victoriaLogs) is not a function
Using require('victoria-orm') instead of import (ESM-only package).
fix
Use import { victoriaLogs } from 'victoria-orm' and ensure package.json has "type": "module" or use .mjs file extension.
Error: Stream must have at least one column.
Created a stream with an empty schema object {}.
fix
Define at least one column in the stream, e.g., { id: text('id') }.
Invalid URL: http://localhost:9428/insert/opentelemetry/v1/logs
Provided incorrect URL path; victoria-orm constructs API endpoints internally.
fix
Pass only the base URL (e.g., http://localhost:9428) without any path suffix.
Unauthorized (401)
Missing or wrong Basic Auth credentials / Bearer token, or server has no auth enabled.
fix
Ensure username/password match VictoriaLogs -httpAuth.username / -httpAuth.password flags, or remove auth config if server runs with --httpListenAddr without auth.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
63 hits · last 30 days
node
60
Meta
1
OpenAI (training)
1
Resources
victoria-orm — npm install victoria-orm · libregistry