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

fastorm

v0.0.8

Published

MySQL ORM for Node.js based on node-mysql2.

Downloads

16

Readme

FastORM

NPM Version NPM Downloads Node.js Version Linux Build License

MySQL ORM (or wrapper) based on node-mysql2 client. Node MySQL2 is focus on performance, we focus on make easy get information on tables. Supports find, insert, delete, update and join methods with limit, order by and projection of columns.

Table of contents

History and Why MySQL2

FastORM project it is a necessity of have a fast and easy tool to work with MySQL in our company (and maintainable). We need migrate Sequalize (good ORM, but in our experience with great memory consumption). Our tool have great influence of MongoDB syntax.

FastORM is mostly compatible (and dependent) of node-mysql2 and supports majority of features. We also offers these features and more

  • Faster / Low latency
  • Multi-connections
  • MySQL Binary Log Protocol
  • Async/await support
  • Extended support for Encoding and Collation
  • Use objects as properties like some MongoDB ORM's
  • Values as objects in where properties
  • Compression (inherited from node-mysql2)
  • Joins between two tables (for now)
  • Common methods for MySQL (find, insert, delete...)
  • Easy!

Installation

FastORM is free from native bindings and can be installed on Linux (tested), Mac OS or Windows without any issues.

npm install --save fastorm

First Query

// get the ORM
import { Model, createConnection } from 'fastorm';

// create the connection to database
const connection = await createConnection({
  host: 'localhost',
  user: 'root',
  database: 'test'
});

// Create model to User table
const User = new Model('User', connection);

// Get all records on User
const users = User.find();

// Get one record
const only_one_user = User.find({ limit: 1 });

// Get all user with name Juan and alive
const all_juanes = User.find({ where: { name: 'juan', alive: true } })

// Same with limit 5 and order by age DESC
const only_five_juanes = User.find({ where: { name: 'juan', alive: true }, limit: 5, order: { age: 0 } })

// Get all user with name not equal to Juan and dead
// Accept $ne, $lt, $lte, $gt, $gte as properties in value
const all_no_juanes = User.find({ where: { name: { $ne: 'juan' }, alive: false } })

Not only find method available

With FastORM you can also insert, delete and join records since the model. It's possible execute "raw" queries too, the module provides query method to this.

FastORM provides insert, delete, join and other methods within the model to work with the records on tables.

// get the ORM
import { Model, createConnection } from 'fastorm';

// create the connection to database
const connection = await createConnection({
  host: 'localhost',
  user: 'root',
  database: 'test'
});

// create other connection to other database and server
const other_connection = await createConnection({
  host: 'other_server',
  user: 'root',
  database: 'post'
});

// Create model to User table
const User = new Model('User', connection);

// Create model to Post table
const Post = new Model('Post', connection);

// Create model to Other table in other server (multiple connections, cool!)
const Other = new Model('Other', other_connection);

// Create user Maria with age 36 and not alive
// IMPORTANT: automatically created_at and updated_at columns
// are inserted, you must have these DATETIME columns on the table
const users = await User.insert({
    name: 'maria',
    age: 36,
    alive: false
});

// Delete users with name pedro and not alive
const deleted = await User.delete({
    name: 'pedro',
    alive: false
})

// Get all posts of user juan with columns: name, title and description
const posts = await User.join({
    table: 'post',
    inner: [ 'id:user_id' ],
    where: { name: 'juan' },
    columns: { name: 1, title: 1, description: 1 }
})

Paginate results

We create a paginate method to facilite managing cursors with lots of information or simply paginate results of any query. In a moment of this history we create an paginate to Sequalize available here.


// Paginate all posts of user juan with columns: name, title and description
// Return { objects, nextCursor } when objects are data found, and nextCursor
// is the property keyPaginated of the next row used to paginate again (sinceId)
const juanes_paginated = await User.paginate({
    sinceId: null, // Not necessary in the first call to paginate
    limit: 10, // Default 1
    where: { name: 'juan' },
    select: { name: 1, title: 1, description: 1 },
    keyPaginated: 'document_id', // Optional used to order, default id
    reverse: true // Optional, default false
})

Authors

Documentation

You can find more detailed documentation here. You should also check various code examples to understand advanced concepts.

Acknowledgements

  • To @sidorares and your team by node-mysql2 module node-mysql2

Contributing

Want to improve something in fastorm. Please check Contributing.md for detailed instruction on how to get started.