npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jsorm/client

v0.3.0

Published

Runtime principal de JSORM

Readme

@jsorm/client

JSORM main runtime. Executes queries and operations.

import { createJsorm } from "@jsorm/client";
import { type DB } from "../.jsorm/types.js";
import { defineConfig } from "@jsorm/core";
import { defineModel, t, r } from "@jsorm/core";
import { createSqliteNodeProvider } from "@jsorm/provider-sqlite-node";
import { schema } from "./jsorm.schema.js";

const User = defineModel("users", {
  db: "main",
  fields: {
    id: t.uuid().primary().autoCreate(),
    name: t.string(100),
    active: t.boolean().default(true),
    createdAt: t.dateTime().autoCreate(),
  },
});

const jsorm = createJsorm<DB>(config, [User], {
  main: (ctx) => createSqliteNodeProvider(ctx.models, { ...ctx.options, schema: schema["main"] }),
});

const users = await jsorm.users.get({
  select: { id: true, name: true },
  where: { active: true },
});

Responsibilities

  • createJsorm(config, models, providers) — factory function with Proxy for table access
  • ProviderManager — AST → provider routing
  • AST builders — AST construction from user input

Does not contain:

  • Database drivers
  • SQL
  • Connections
  • Models (only receives them as metadata)

Works on Edge, Serverless, and Node.


API

import { createJsorm } from "@jsorm/client";
import { type DB } from "../.jsorm/types.js";
import { createSqliteNodeProvider } from "@jsorm/provider-sqlite-node";
import { schema } from "./jsorm.schema.js";

const jsorm = createJsorm<DB>(config, models, {
  main: (ctx) => createSqliteNodeProvider(ctx.models, { ...ctx.options, schema: schema["main"] }),
});

Factory function

createJsorm<DB, const TDatabases extends Record<string, DatabaseConfig>>(
  config: ConfigAST<TDatabases>,
  models: readonly RuntimeModel[],
  providers?: Partial<ProviderManifest<TDatabases>>,
): JsormAccessor<DB>

Receives config, models, and the provider manifest. Returns a Proxy that intercepts property access to return TableMethods per table.

The manifest has one key per database declared in jsorm.config.ts, and replaces the requirement to call providers.register once per database. There is no implicit name matching, and omitting a database is legal: the error surfaces on the first query against that database, not at startup.

Table access

// Main database — direct access
jsorm.users.get()
jsorm.users.create({ name: "Ana" })
jsorm.users.update({ where: { id: "1" }, data: { name: "B" } })
jsorm.users.delete({ where: { id: "1" } })

// Non-main database — namespaced
jsorm.cache.users.get()

Instance methods

jsorm.raw(options: { db?: string; sql: string; params?: unknown[] }): Promise<ProviderResult<unknown>>
jsorm.compile(ast: QueryAST, db?: string): { sql: string; params: unknown[] }
jsorm.close(db?: string): Promise<void>
jsorm.syncSchema(db?: string): Promise<ProviderResult<SchemaReport>>
jsorm.getMissingTables(db?: string): Promise<ProviderResult<string[]>>

Properties

jsorm.providers  // ProviderManager — wired by createJsorm from the manifest

Registration with manifest

The third parameter of createJsorm is the provider manifest: one key per declared database, and it replaces the requirement to call providers.register once per database.

import { createSqliteNodeProvider } from "@jsorm/provider-sqlite-node";
import { schema } from "./jsorm.schema.js";

const jsorm = createJsorm<DB>(config, models, {
  main: (ctx) => createSqliteNodeProvider(ctx.models, { ...ctx.options, schema: schema["main"] }),
});

Each factory receives the context of its database (database, access, provider, models, options), so the provider is built with only what belongs to it.


CLI Generated

The runtime is automatically generated via jsorm gen. Do not edit manually.

// src/models/jsorm.server.ts — generated
import { createJsorm } from "@jsorm/client";
import { type DB } from "../../.jsorm/types.js";
import config from "../../jsorm.config.js";
import { createSqliteNodeProvider } from "@jsorm/provider-sqlite-node";
import { schema } from "./jsorm.schema.js";

import { User } from "./server/main/User.js";

const allModels = [User] as const;

const jsorm = createJsorm<DB>(config, allModels, {
  "main": (ctx) => createSqliteNodeProvider(ctx.models, { ...ctx.options, schema: schema["main"] }),
});

export { jsorm, type DB };

ESM-only

Exports .mjs (ESM) with .d.ts types. Does not produce CJS.