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

@nastro-dev/notion-orm

v1.0.1

Published

A TypeScript-first ORM for Notion databases. Define schemas as code, push them to Notion, and query with a fluent, type-safe API.

Downloads

31

Readme

@nastro-dev/notion-orm

A TypeScript-first ORM for Notion databases. Define schemas as code, push them to Notion, and query with a fluent, type-safe API.

Features

  • Schema-as-code — Define Notion databases with plain TypeScript objects
  • Type-safe queries — Full type inference for inserts, updates, and selects
  • Fluent API — Chainable query builders with filters, sorting, and pagination
  • CLI companion — Push schema changes to Notion with change detection
  • CRUD operations — Insert, select, update, and delete rows

Installation

npm install @nastro-dev/notion-orm

Quick Start

1. Define a schema

import { table, title, richText, select, date, checkbox } from "@nastro-dev/notion-orm";

export const tasksTable = table("Tasks", {
  name: title(),
  description: richText(),
  status: select({
    options: ["Todo", "In Progress", "Done"],
  }),
  dueDate: date(),
  completed: checkbox(),
});

// Inferred types
export type TaskInsert = InferInsertType<typeof tasksTable>;
export type Task = InferSelectType<typeof tasksTable>;

2. Create a database client

import { createNotionDB } from "@nastro-dev/notion-orm";

const db = createNotionDB({
  token: process.env.NOTION_TOKEN!,
});

3. Query your data

import { eq } from "@nastro-dev/notion-orm";

// Select all rows
const { rows, nextCursor } = await db.select().from(tasksTable).execute();

// Select by ID
const { rows } = await db
  .select()
  .from(tasksTable)
  .where(eq("id", "page-id-here"))
  .execute();

// Select with filters
const { rows } = await db
  .select()
  .from(tasksTable)
  .where(eq("status", "Done"))
  .execute();

// Sort and paginate
const { rows, nextCursor } = await db
  .select()
  .from(tasksTable)
  .sort("dueDate", "asc")
  .limit(10)
  .setCursor(nextCursor)
  .execute();

4. Insert data

const newTask = await db.insert(tasksTable).values({
  name: "Write documentation",
  status: "Todo",
  dueDate: "2024-12-31",
});

5. Update data

await db
  .update(tasksTable)
  .values({ status: "Done" })
  .where(eq("id", "page-id-here"))
  .execute();

6. Delete data

await db
  .delete(tasksTable)
  .where(eq("id", "page-id-here"))
  .execute();

Schema Definition

Column Types

import {
  title,        // required, exactly one per table
  richText,
  number,
  select,       // { options: ["A", "B"] }
  multiSelect,  // { options: ["A", "B"] }
  status,       // { options: ["A", "B"] }
  date,
  people,
  files,
  checkbox,
  url,
  email,
  phoneNumber,
  relation,     // { relatedTo: "otherTableName" } not completely supported
  formula,      // { expression: "..." } not completely supported
  rollup,       // { function, relation_property_name, rollup_property_name } not completely supported
  uniqueId,     // { prefix?: "..." } read-only
  createdTime,
  createdBy,
  lastEditedTime,
  lastEditedBy,
} from "@nastro-dev/notion-orm";

Column Options

All columns accept these optional properties:

name: title({
  name: "Task Name",      // override property name in Notion
  description: "...",     // property description
});

Type Inference

import type { InferInsertType, InferSelectType } from "@nastro-dev/notion-orm";

// Insert type: title required, everything else optional
type TaskInsert = InferInsertType<typeof tasksTable>;
// { name: string, description?: string, status?: string, ... }

// Select type: all readable columns + id
type Task = InferSelectType<typeof tasksTable>;
// { id: string, name: string, description: string, status: string | null, ... }

Filters

import { eq, ne, gt, gte, lt, lte, and, or } from "@nastro-dev/notion-orm";

// Equality
eq("status", "Done");
eq("id", "page-id");           // special: fetches by page ID directly

// Comparison
gt("number", 100);
gte("date", "2024-01-01");
lt("unique_id", 50);

// Combining filters
and(eq("status", "Todo"), gt("number", 10));
or(eq("status", "Done"), eq("status", "Archived"));

Select Query Builder

db.select()
  .from(tasksTable)
  .where(eq("status", "Todo"))      // filter
  .sort("dueDate", "asc")            // sort (chainable)
  .limit(50)                         // page size
  .setCursor(cursor)                 // pagination cursor
  .raw({ /* raw Notion filter */ })  // pass raw filter object
  .execute();                        // returns { rows, nextCursor }

Requirements

  • Node.js >= 18
  • A Notion integration token
  • Databases must be pushed to Notion first using the CLI

Related Packages

License

ISC