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

redentities

v2.2.4

Published

Simple & fast object-mapper & query builder, MySql, Sqlite AWS RDS mysql based databases supported

Downloads

23

Readme

Red Entities

RedEntities logo

JavaScript Style Guide License

What it is?

Red Entities is a simple but flexible and fast object-mapper & sql query builder.

This is a subproject of Mantra Framework you can use freely in your own projects.

Red Entities is focused on minimal typing when accesing data and the definition of database models using schemes (simple json objects).

A model is defined in a json object, called schema.

Data access (inserts, selects, removes and updates), are done by selectors for a fast an simple writing of the sentences.

Database engines supported

Tested with:

  • PostgreSQL 8.x
  • Mysql 5.x
  • Mysql 8.x
  • Amazon Aurora
  • AWS RDS databases based on Mysql
  • Sqlite3
  • (future integration of Redis, MariaDB, Sql Server, Sql Azure Tables, DynamoDB, etc.)

Thus, has been fully tested with:

  • Node.js 10.x
  • Node.js 12.x
  • Node.js 13.x
  • Node.js 14.x
  • Node.js 15.x
  • Node.js 16.x
  • Node.js 17.x

Install

$ npm i redentities --save

Test

Change database configuration providers in file located at:

/test/providersconfig.json

Testing will create many databases and tables.

Then, just run (mocha required):

$ npm run testmysql
$ npm run testsqlite
$ npm run testpostgresql

Basic sample

As a basic introduction, consider this self-explained schema:

const sampleSchema = {
    entities: [
        {
            name : "users",
            fields: [
                { name : "mail", type : "string" },
                { name : "password", type : "string" },
                { name : "created", type : "datetime"}
            ],
            indexes: [ ["mail"], ["created"] ]
        }
    ]
}

Load this schema in an Red Entities object with:

const RedEntities = require("redentities")({
    provider: "mysql",
    host: "localhost",
    user: "myuser",
    password: "mypassword"
});

Create the schema in database with:

await RedEntities.Entities(sampleSchema).CreateSchema();

From now on, you can use Red Entities powers with fast sentences like this:

const db = await RedEntities.Entities(sampleSchema);

const newUserId = await db.users.I().V( { 
    mail: "[email protected]",
    password: "12345" ).R();

Retrieve an entity with simple sentences like:

const userEntity = await db.users.S().SingleById(userId);

Documentation

Demos

You can find some demos at /demos folders.

To run them, just

node /demos/<demo name.js>

01-inserts-sample : Insert and retrieve basic values 02-insert-and-iterate : Insert a bulk of values and iterates over them 03-insert-and-deleteall : Insert a bulk of values and removed them 04-json-type : Insert a bulk of json objects and retrieve them

Credits

RedEntities has been fully written by Rafael Gómez Blanes

Professional site at Rafablanes.com

Have a look to my books at Rafa G. Blanes books

License

Licensed under MIT terms.

Copyright (c) 2019-2021:

Contact an support

You can contact us by GitHub, accesing Mantra web site or at [email protected].