JSPM

openrecord

0.3.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q78850F

Active record like ORM for nodejs

Package Exports

  • openrecord

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openrecord) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenRecord

Build Status [Node.ci] (http://node.ci/projects/github/PhilWaldmann/openrecord/master) Coverage Status npm package version Dependency Status

ActiveRecord like ORM for nodejs

Installation

npm install openrecord

Features

  • SQLite3 and Postgres support
  • Async schema definition
  • Automatic field definition loading
  • Relations
  • Nested Eager Loading
  • Nested Creates
  • Nested Updates
  • Validations
  • Scopes
  • Before and After Hooks
  • Events
  • Chaining
  • ...

Roadmap

0.4.0

  • Better error handling
  • migrations

0.5.0

  • add mysql support
  • full multiple primary keys support

0.6.0

  • finish .every() callback issues
  • better postgres support (hstore, ect.)

0.7.0

  • custom plugin support
  • more examples

Usage

var OpenRecord = require('openrecord');

var sqlite = new OpenRecord({
  type: 'sqlite3',
  file: 'test.sqlite'
});


sqlite.Model('User', function(){
  this.hasMany('posts');
    
  this.scope('active', function(){
    this.where({active: true});
  });
});


sqlite.Model('Post', function(){
  this.belongsTo('user');
});


sql.ready(function(){
  var User = sql.Model('User');

  User.active().where({posts: {title_like:'openrecord' }}).include('posts').exec(function(records){
    console.log(records);
  });
});

Documentation

Contributing

If you've found a bug please report it via the issues page. Please make sure to add a unit test with the bug report! Before submit pull request make sure all tests still passed.