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

jv-noorm

v0.0.62

Published

DB access without ORM

Readme

JV No ORM

Free yourself from ORMs and code your own queries for MariaDB or PostgreSQL easily and make your applications faster than ever. Please consider this an experimental project without any warranty. You can use it AS IS.

Features

  • You are again in control of the database and its performance;
  • Abstraction between MariaDB and PostgreSQL. JV-Noorm uses mysql2 and pg directly, without the heavy overhead of ORMs;
  • Easily control transactions;
  • Create and manage your own migrations with scripts written by yourself;
  • Deploy migrations whenever and however you need.

Installation

Just type:

  npm install jv-noorm

or

  yarn add jv-noorm

Configuring your project

  • First, modify or create your .env file:
# Database configuration example
DB_TYPE=        # MariaDB or PostgreSQL
DB_HOST=        # IP or Address of the database
DB_PORT=        # Port number of the database
DB_DATABASE=    # Database name
DB_SCHEMA=      # For PostgreSQL only
DB_USER=        # Database username
DB_PASSWORD=    # Database password
DB_MAX_POOL=    # Max number of pool connections
DB_MIN_POOL=    # Min number of pool connections
DB_VERBOSE=     # If you want to see debug information in the console, set this to true
SCRIPTS_FOLDER= # the folder your migration scripts will be saved
MODELS_FOLDER=  # the folder used to save the interfaces with tables definitions

or, you can connect to the database using a DATABASE_URL field:

DATABASE_URL =  # the URL used for connection
DB_MAX_POOL=    # Max number of pool connections
DB_MIN_POOL=    # Min number of pool connections
DB_VERBOSE=     # If you want to see debug information in the console, set this to true
SCRIPTS_FOLDER= # the folder your migration scripts will be saved
MODELS_FOLDER=  # the folder used to save the interfaces with tables definitions

JV-Noorm accept two ways to parse the url:

<protocol>://<user>:<password>@<host>:<port>/<database_name>?schema=<schema>

or

<protocol>://<host>:<port>?user=<user>&password=<password>&database=<database_name>?schema=<schema>

Examples:

mysql://localhost:3306?user=myusere&password=mypassword&database=mydatabase

or

postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public

  • Now, add to your project a script to create migrations:

Migrations are scripts with your database changes. Create a file named migration.ts in the folder you want and paste this code:

import { createMigration } from 'jv-noorm';

(async () => {
  await createMigration();
  process.exit(0);
})();
  • Now, again, add to your project a script to deploy the migrations:

Deploy will run every new script in your database and apply the changes you wrote. Create a file named deploy.ts in the folder you want and paste this code:

import { deploy } from 'jv-noorm';

(async () => {
  await deploy();
  process.exit(0);
})();
  • Add another file to your project with a script to generate interfaces to your project:

You can use these interfaces to type-check your query results. Create a file named generate.ts in the folder you want and paste this code:

import { generate } from 'jv-noorm';

(async () => {
  await generate();
  process.exit(0);
})();
  • Modify your package.json:

Add three scripts to create migrations and deploy them:

"type": "module",
"scripts": {
   ... whatever you have ...
    "migration": "tsx <folder>/migration.ts",
    "deploy": "tsx <folder>/deploy.ts",
    "generate": "tsx <folder>/generate.ts"
  },

Don't forget to add tsx to your project, if you don't have it.

Testing:

To create a new script file type:

yarn migration '<the name of the script without .sql'

This will create a file with a predefined header and open it in VSCode. You can fill it with any SQL command you want, separating them with ; character.

To deploy the scripts to the database, type:

yarn deploy

JV-noorm will verify all new scripts and execute them in order using mariadb or psql command line tools.

To generate interfaces based on your database, type:

yarn generate

for more options, try:

yarn generate --help

JV-noorm will generate multiple interface files, one for each table your database has.

Usage

import the connection:

import { createNoORMConnection } from 'jv-noorm';

Create the object:

const db = createNoORMConnection();

Now, db has the instance of the lib prepared to use MariaDB or PostgreSQL according with your .env definition.

Create the pool of connections:

await db.connect();

If your .env file is correct and the DB server is available and accessible, the database is connected.

The jv-noorm lib has some functions:

  • await db.exec: for run commands without results, like creates, drops, etc.;
  • await db.queryRow: for select commands with just one row as result;
  • await db.queryRows: for select commands with more than one row as result;
  • await db.insert: for insert command. The result will return the number of the rows inserted and the id of auto_create or serial primary keys (if only one row returned);
  • await db.update: for update command. The result will return the number of updated rows;
  • await db.delete: for delete command. The result will return the number of deleted rows. This command can execute a hard or soft delete;
  • await db.startTransaction or await db.beginTransaction: used to start a new transaction;
  • await db.commit: used to commit changes;
  • await db.rollback: used to rollback changes;
  • await db.close: used to finish the pool connections.

There are examples in src/example, for MariaDB and PostgreSQL. These examples demonstrates how to connect, disconnect, create/drop tables manually, run queries, and perform inserts, updates, deletes, and transactions.