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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rustite

v2.2.3

Published

Rustite is a native Node.js module powered by [Rust](https://www.rust-lang.org/) and [NAPI-RS](https://napi.rs/), providing a lightweight ORM-style interface to SQLite databases.

Readme

🧱 Rustite: SQLite ORM-style Binding for Node.js

Rustite is a native Node.js module powered by Rust and NAPI-RS, providing a lightweight ORM-style interface to SQLite databases.


📦 Installation

npm install rustite

🚀 Quick Start

1. Initialize the Database

const { Database } = require('rustite');

const db = new Database('mydb.sqlite');

await db.execute(`
  CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT,
    age INTEGER
  )
`);

2. Insert a Record

const users = db.table('users');

await users.insert({ name: 'Alice', age: 30 });

3. Find a Record by ID

const user = await users.find(1);
console.log('User:', user);

4. Query with Conditions

const adults = users.where('age', '>=', 18);

const result = await adults.get();
console.log('Adults:', result);

const first = await adults.first();
const last = await adults.last();

5. Update a Record

await users.update(1, { age: 31 });

// Or

const user = await users.find(1);
if (user) {
  await user.update({ age: 31 });
}

6. Delete a Record

await users.destroy(1);

// Or

const user = await users.find(1);
if (user) {
  await user.destroy();
}

7. Chained Queries and Nested Conditions

const result = await users
  .where('age', '>=', 18)
  .where('name', 'LIKE', '%A%')
  .order_by('id', 'DESC')
  .get();

console.log(result);

8. Custom SQL Queries

const rows = await db.query('SELECT name FROM users WHERE age > 20');
console.log(rows);

🧠 API Overview

Database

  • new(path: string)

    • Opens or creates a SQLite database at the given file path.
  • table(name: string): Table

    • Returns a Table instance bound to a specific table name.
  • execute(sql: string): Promise<void>

    • Executes raw SQL (e.g., CREATE TABLE, DROP TABLE, etc).
  • query(sql: string): Promise<object[]>

    • Executes a SELECT query and returns the results as parsed objects.

Table

  • find(id: string | number): Promise<Record | null>

    • Retrieves a single record by its primary key id.
  • insert(obj: object): Promise<number>

    • Inserts a new row with the given object fields. Returns the new row ID.
  • where(column: string, op: string, value: any): Table

    • Adds a filter condition (e.g., where("age", ">=", 21)). Supports =, !=, <, >, LIKE, IN, IS NULL, and more.
  • order_by(column: string, direction?: 'ASC' | 'DESC'): Table

    • Adds ordering to the current query.
  • get(): Promise<object[]>

    • Executes the built query and returns the list of matching records.
  • first(): Promise<object | null>

    • Returns the first matching record ordered by ascending id.
  • last(): Promise<object | null>

    • Returns the last matching record ordered by descending id.
  • update(id: string | number, object: object): Promise<void>

    • Updates the record with the given ID.
  • destroy(id: string | number): Promise<void>

    • Deletes the record with the given ID.

Record (Instance returned by .find())

  • update(object: object): Promise<void>

    • Updates the current record in the database.
  • destroy(): Promise<void>

    • Deletes the current record from the database.

🥪 Full Example

const { Database } = require('rustite');

async function main() {
  const db = new Database('app.sqlite');
  await db.execute(`CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY, title TEXT, content TEXT)`);

  const posts = db.table('posts');

  const postId = await posts.insert({ title: 'Hello', content: 'World' });

  const post = await posts.find(postId);
  if (post) await post.update({ content: 'Updated content' });

  const allPosts = await posts.where('id', '>=', 1).get();
  console.log(allPosts);

  if (post) await post.destroy();
}

main();