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

angie-orm

v0.0.6

Published

A Feature-Complete Database Relationship Manager Designed for NodeJS

Downloads

7

Readme

emblem

Angie ORM

npm version iojs support node support npm downloads build status code coverage documentation

NPM

About

Angie ORM is a feature-complete database relationship manager designed for NodeJS.

Current Database Support

Planned Database Support

  • Firebase
  • MongoDB
  • Couchbase
  • Postgres

Usage

npm i -g angie-orm
angie-orm help

Building databases is easy! In a file called AngieORMFile.json:

{
    "databases": {
        "default": {
            "type": "sqlite3",
            "name": "angie.db"
        },
        "test_site": {
            "type": "mysql",
            "alias": "angie_site",
            "username": "root"
        }
    }
}

You can make models in several ways

global.app.Model('test', function($Fields) {
    let obj = {};
    obj.test = new $Fields.CharField({
        default: () => 'test ' + 'test'
    });
    obj.many = new $Fields.ManyToManyField('test2', {
        name: 'test'
    });
    return obj;
});

@Model
class test {
    constructor($Fields) {
        this.test = new $Fields.CharField({
            default: () => 'test ' + 'test'
        });
        this.many = new $Fields.ManyToManyField('test2', {
            name: 'test'
        });
    }
}

These two models are functionally equivalent. To actually build your databases:

angie-orm syncdb [name]

Where if no name is specified, the default database will be synced. This will also automatically migrate your database, but a command for migrating databases is also available:

angie-orm syncdb [name] [--destructive]

Where destructive will force stale tables and columns to be deleted. All of the above is done for you in your AngieFile.json if you are building an Angie application.

The first argument provided the function passed to the model will be $Fields, an object containing all of the available field types. Individual fields can also be required from their source in angie-orm/src/models/$Fields:

import {CharField} from 'angie-orm/src/models/$Fields';

// or

require('angie-orm/src/models/$Fields').CharField;

Available Field Types Include:

  • CharField
  • IntegerField
  • KeyField
  • ForeignKeyField
  • ManyToManyField

Additionally, Fields can be passed configuration options on instantiation:

  • minValue
  • maxValue
  • minLength
  • maxLength
  • nullable
  • unique
  • default

In that order as arguments or in an Object. Foreign key and many to many fields require as a first argument a related table with which a reference is made. Additionally, these fields support nesting and deepNesting options. Many to many fields require a name be passed as reference.

If you have a need for a Field type that is not included, feel free to make a Pull Request (and follow the current format), or ask.

All queries return a Promise with a queryset

global.app.Models.test.all().then(function(queryset) {
    return queryset[1].update({
        test: 'test'
    }).then(function() {
        process.exit(0);
    });
});

querysets are extended Arrays, which include an index list of records with extended methods, a list of unmodified results (queryset.results), and methods

Model methods include:

  • all: Fetch all of the rows associated with a Models
  • fetch: Fetch a certain number of rows
  • filter: Filter a queryset. Supports conditionals.
  • create: Create a record
  • delete: Delete a record
  • update: Update a record
  • exists: Does the filter query return any results (passes a boolean to the resolve)

All supports no arguments. The other READ methods on the tables support an Object as an argument with the following keys:

  • values: The list of fields you would like to see
  • ord: Order 'ASC' or 'DESC'
  • int: The number of rows you would like to have returned
  • each key in the table, with a WHERE value (eg: id>1 would be { id: '>1' })

Create/Update queries require all non nullable fields to have a value in the arguments object or an error will be thrown. All queries support the database argument, which will specify the database that is hit for results.

Update queries are available on the entire queryset as well as each row. Additionally, methods to retrieve the first and last row in the returned records are available. Many to many fields have the added functionality of fetching all related rows, fetching, filtering related rows, and adding, and removing related rows. The arguments to these methods must be existing related database objects.

For a list of Frequently Asked Questions, please see the FAQ and the CHANGELOG for an up to date list of changes. Contributors to this Project are outlined in the CONTRIBUTORS file.

Angie

Please see the site for information about the project, a quickstart guide, and documentation and the CHANGELOG for an up to date list of changes.