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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vormi

v0.1.3

Published

A declarative lightweight library for dynamic error-driven SQL schema synchronization, and automatic management and implementations of various Cloudflare services and features.

Downloads

44

Readme

VORMi

VORMi, developed by VOID, is an innovative Object Relational Mapping Interface designed to enhance your development experience with powerful ORM capabilities, complemented by IntelliSense and type safety across your entire database schema.

Features

  • Type Safety: Ensure your database interactions are safe and predictable with TypeScript's type safety. AKA, non-existent tables or columns will be caught while you write your code, not at runtime.
  • IntelliSense Support: Boost your productivity with auto-completion for your own tables and columns that were statically defined in your VORMi schema.
  • Self-Creating Schema: Whenever VORMi encounters an internal error of a table or column not existing, it will automatically create the table or column in the database for you, as long as it is defined in the schema, and then it will retry the operation.
  • Adapter Support: Extend VORMi with different storage adapters, including a built-in memory adapter for quick testing and prototyping.

Installation

To get started with VORMi, install the package via npm by running the following command in your terminal:

npm install vormi

Quick Start

Define your data models using a simple Typescript object:

const schema = {
    user: {
        id: C.int().autoIncrement().primaryKey(),
        uid: C.binary(16).unique().index(),
        display_name: C.varchar(64),
        email: C.varchar(255),
        age: C.int().nullable(),
        created: C.datetime().default('now'),
        updated: C.datetime().default('now').onUpdate('now'),
        banned: C.boolean().default(false)
    },
    post: {
        id: C.int().autoIncrement().primaryKey(),
        user_id: C.int().references('user', 'id'),
        content: C.text()
    },
    comment: {
        id: C.int().autoIncrement().primaryKey(),
        post_id: C.int().references('post', 'id'),
        user_id: C.int().references('user', 'id'),
        content: C.text()
    }
};

C is a shorthand for Column and is used to define the columns of a table. The Column class provides a variety of methods to define the column's properties, such as autoIncrement, primaryKey, unique, index, references, default, nullable, and onUpdate.

The method-chaining schema syntax allows you to define the column's properties in a fluent and readable manner, utilizing the horizontal space efficiently, without polluting the code vertically with unnecessary line breaks like in other types of ORM libraries. This gives you an efficient bird's eye view of the whole database schema in a single glance, which is especially useful when working with large schemas.

Now prepare your VORMi instance with the database schema you just created and an adapter to interact with the database of your choice. We'll use the built-in MemoryAdapter for this example:

import { VDatabase, MemoryAdapter } from 'vormi';

// Create a database instance with the schema.
const db = new VDatabase(schema, new MemoryAdapter());

Leverage TypeScript's IntelliSense for type-safe database operations:

// Insert a new user into the 'user' table
await db.from('user').insert({ display_name: 'John Doe', age: 25, banned: false, created: new Date(), updated: new Date() });
// Select all rows from the 'user' table with the 'id' and 'display_name' columns only
const result = await db.from('user').fields('id', 'display_name').all();
// Get the first row from the result
const user = result.rows[0];
// Output the result
console.log(user);
// Outputs: { id: 1, display_name: "John Doe" }

Adapters

VORMi is designed to be extensible with various storage solutions. Currently supported adapters include:

  • MemoryAdapter for in-memory databases, perfect for testing and development environments.

(Additional adapter documentation and examples to be added as they become available.)

Contributing

We welcome contributions to VORMi! Whether you're interested in fixing bugs, adding new features, or improving documentation, please feel free to make a pull request or open an issue.

License

VORMi is MIT licensed.