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

fluent-orm

v1.8.7

Published

Js ORM inspired by Eloquent

Readme

fluent

Javascript ORM Inspired by Eloquent.

Installation

npm install fluent-orm --save

or

yarn add fluent-orm

Configuration

You can use ENV variable or call the configuration method.

ENV

create a .env file like the example bellow.

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=1234

Configuration

In the main script you can configure like this:

import { configurator } from "fluent-orm";
import pg_driver from "fluent-pg";
import my_driver from "fluent-mysql-driver";

const env = (env, default_value) => {
    return process.env[env] || default_value;
};

// Add driver
configurator.use(pg_driver.configure);
configurator.use(my_driver.configure);

// Add drivers configurations
configurator.configure({
    'default': 'my_mysql_connection',
    'connections': {
        'my_mysql_connection': {
            'driver': 'mysql',
            'host': '127.0.0.1',
            'port': '3306',
            'database': env('DB_DATABASE', 'forge'), //you can also use env here
            'user': 'forge',
            'password': '',
            'charset': 'utf8mb4',
            'collation': 'utf8mb4_unicode_ci',
            'prefix': '',
            'prefix_indexes': true,
            'strict': true
        },
        'my_postgres_connection': {
            'driver': 'pgsql',
            'host': '127.0.0.1',
            'port': '5432',
            'database': 'postgres',
            'user': 'postgres',
            'password': '1234'
        }
    }
});

available drivers

https://github.com/pedrosoares/fluent-pg https://github.com/pedrosoares/fluent-mysql

"Working" features

This is a experimental project, can dramatically change its structure at any time.

  • Select (With EagerLoader)
  • Delete
  • Update
  • Insert
  • count
  • raw
  • Transaction

Roadmap

  • Add others type of relations (Only hasMany supported so far)
  • Bind Select Result to Js Model to use save and delete function direct from the model.

Usage

Model

import { Model } from "fluent-orm";
import Permission from "./Column";
import Email from "./Column";

class Person extends Model {

    Permissions() {
        return this.hasMany(Permission, 'permission_id', 'id');
    }

    Emails() {
        return this.hasMany(Email);
    }

}

export default Person;

Select

Person.query().with('Permissions', 'Emails').get().then(response => {
    console.log(response);
}).catch(error => {
    console.log(error);
});

Create/Insert

Create insert a single element and return it with id. Insert is a bulk function.

Person.create({name, password}).then(person => {
    const dataEmails = emails.map(email => ({
        person_id: person.id,
        email: email
    }));

    Email.insert(dataEmails).then(success => {
        console.log({
            person,
            success
        });
    });
}).catch(error => {
    console.log(error);
})

Delete

Person.transaction((transaction, commit, rollback) => {
    Person.query().where('id', id).firstOrFail({transaction}).then(person => {
        Person.query().where('id', person.id).delete({transaction}).then(() => {
            commit();
            res.json({
                success: 'Person deleted successfully'
            });
        });
    }).catch(error => {
        res.status(500).send({
            error: error,
            message: error.toString()
        });
        rollback();
    })
});

// OR Using async/await

const { transaction, commit, rollback } = await Person.transaction();
try {
    const person = await Person.query().where('id', id).firstOrFail({ transaction });
    await Person.query().where('id', person.id).delete({ transaction });
    commit();
} catch(err) {
    rollback();
}

Update

Person.transaction((transaction, commit, rollback) => {
    Person.query().where('id', id).firstOrFail({transaction}).then(person => {
        Person.query().where('id', person.id).update({
            name: name
        }, {transaction}).then(() => {
            commit();
            res.json({
                success: 'Person Updated successfully'
            });
        }).catch(error => {
            res.status(500).send({
                error: error,
                message: error.toString()
            });
            rollback();
        });
    }).catch(error => {
        res.status(500).send({
            error: error,
            message: error.toString()
        });
        rollback();
    })
});