Home Identifier Source Repository

Angie ORM

build status iojs support node support code coverage npm downloads



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

Current Database Support

Planned Database Support


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;

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


Available Field Types Include:

Additionally, Fields can be passed configuration options on instantiation:

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() {

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 supports no arguments. The other READ methods on the tables support an Object as an argument with the following keys:

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.


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.