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

suorm

v1.0.5

Published

A super simple query builder for surreal.db

Downloads

12

Readme

SUORM - Surreal.db ORM

A super simple query builder for surreal.db

Installation

npm:

npm install suorm

yarn:

yarn add suorm

Example

Define Table

import { suorm } from "suorm";

const userTable = suorm.define.table
  .name("user")
  .schemafull()
  .addField((f) =>
    f.name("email").type("string").assert("$value != NONE && is::email($value)")
  )
  .addIndex((i) => i.name("email_index").unique().columns("email")).build;

/**
 * userTable: DEFINE TABLE user SCHEMAFULL;DEFINE FIELD email ON TABLE user TYPE string ASSERT $value != NONE && is::email($value);DEFINE INDEX email_index ON TABLE user COLUMNS email UNIQUE;
 */

Select From

import { suorm } from "suorm";

const emailData = suorm
  .select("email")
  .as("address")
  .from("user")
  .where("email != NONE")
  .limit(10)
  .start(5).build;

/**
 * emailData: SELECT email AS address FROM user WHERE email != NONE LIMIT 10 START 5;
 */

⚠️ Warning

  • Not stable yet

  • A lot of stuff is not implemented yet

  • No assertion builder

  • No permission builder

  • Doesn't support GEO types

  • Selection ORDER and FETCH are not implemented yet

Usage

Exports

  • suorm - new QueryBuilder()
  • QueryBuilder
  • TableBuilder
  • FieldBuilder
  • IndexBuilder
  • SelectBuilder

Example:

// Common
const {
  suorm,
  QueryBuilder,
  TableBuilder,
  FieldBuilder,
  IndexBuilder,
  SelectBuilder
} = require("suorm");

// TypeScript / ESM
import {
  suorm,
  QueryBuilder,
  TableBuilder,
  FieldBuilder,
  IndexBuilder,
  SelectBuilder
} from "suorm";

Classes

QueryBuilder

get define(): Object;

Returns:

  • table: TableBuilder
  • field: FieldBuilder
  • index: IndexBuilder

Example:

// Table
suorm.define.table.name("user").schemafull().build;

// Field
suorm.define.field.name("email").type("string").assert("$value != NON").build;

// Index
suorm.define.index.name("email_index").unique().columns("email").build;

select(...projection: string[]): SelectBuilder;

Returns:

  • Instance of SelectBuilder

Example:

// SELECT * FROM user;
suorm.select("*").from("user").build;

// SELECT email,username FROM user;
suorm.select("email", "username").from("user").build;

TableBuilder

name(name: string): this;

Example:

table.name("user");

schemafull(opt: boolean = true): this;

Example:

table.schemafull();

// or schemaless (default)
table.schemafull(false);

drop(opt: boolean = true): this;

Example:

table.drop();

addField(callback: FieldBuilder | ((data: FieldBuilder) => FieldBuilder)): this;

Example:

table.addField((f) => f.name("email").type("string"));

// or

table.addField(new FieldBuilder().name("email").type("string"));

addIndex(callback: IndexBuilder | ((data: IndexBuilder): this;

Example:

table.addIndex((i) => i.name("email_index").columns("email"));

// or

table.addField(new IndexBuilder().name("email_index").columns("email"));

get build(): string;

Example:

// String Output
table.build;

FieldBuilder

name(name: string): this;

Example:

field.name("email");

tableName(name: string): this;

Example:

field.tableName("user");

type(type: FieldDataTypes): this;

Example:

field.type("bool");

value(val: string | number, or?: string | number, ignoreDefaultValues: boolean = false): this;

Description:

  • Rule 1: val/or gets converted into UPPERCASE and an operator if is one of DefaultValues, e.g. field.value("none") = NONE (not "none")
  • Rule 2: If val/or starts with $ (dollar sign) it won't be a string anymore, e.g. field.value("$value") = $value (not "$value")
  • Rule 3: If val/or is an number/boolean/bigint it won't be converted into an string and it will be in UPPERCASE, e.g. field.value(true) = TRUE (not "true") and field.value(69) = 69 (not "69")
  • Rule 4: If val/or is an valid JS object, it will be automatically converted into an json string using JSON.stringify, e.g. field.value({ foo: "bar" }) = '{"foo":"bar"}'

If ignoreDefaultValues is set to true:

  • Rule 1 and Rule 2 wont apply anymore, e.g. field.value("none", null, true) = "none" (not NONE) and field.value("$value", null, true) = "$value" (not $value)
  • Rule 3 won't apply anymore too, e.g. field.value(true) = "true" (not TRUE) and field.value(69) = "69" (not 69)

Example:

field.value("[email protected]"); // VALUE "[email protected]"
field.value("$value", "none"); // VALUE $value OR NONE
field.value("$value", "none", true); // VALUE $value OR "none"

assert(exp: string): this;

Example:

field.assert("$value != NONE");

get build(): string;

Example:

// String Output
field.build;

IndexBuilder

name(name: string): this;

Example:

index.name("email_index");

unique(opt: boolean = true): this;

Example:

index.unique();

columns(...cols: string[]): this;

Example:

index.columns("email");

// or

index.columns("foo", "bar");

get build(): string;

Example:

// String Output
index.build;

SelectBuilder

constructor(projection: string[])

Example:

const select = new SelectBuilder(["email", "username"]);

from(name: string): this;

Example:

// SELECT foobar FROM user
select.from("user");

where(con: string): this;

Example:

select.where("email IS NOT NONE");

// or

select.where("email != NONE");

as(con: string): this;

Example:

// SELECT email AS address...
select.as("address");

split(...field: string[]): this;

Example:

// SELECT * FROM user SPLIT email;
select.split("email");

// SELECT * FROM user SPLIT email,username;
select.split("email", "username");

group(...field: string[]): this;

Example:

// SELECT * FROM user GROUP BY email;
select.group("email");

// SELECT * FROM user GROUP BY email,username;
select.group("email", "username");

limit(lim: number): this;

Example:

// SELECT * FROM user LIMIT 50;
select.limit(50);

timeout(time: string): this;

Example:

// SELECT * FROM user TIMEOUT 5s;
select.timeout("5s");

start(lim: number): this;

Example:

// SELECT * FROM user LIMIT 50 START 10;
select.start(10);

parallel(opt: boolean = true): this;

Example:

// SELECT * FROM user PARALLEL;
select.parallel();

get build(): string;

Example:

// String Output
select.build;

Types

FieldDataTypes:

"string" | "number" | "object" | "any" | "array" | "bool" | "datetime" | "decimal" | "duration" | "float" | "int" | "record"

DefaultValues

"NONE" | "NULL" | "TRUE" | "FALSE" | "none" | "null" | "true" | "false"