grand-central-records

0.5.2 • Public • Published

Grand Central Records (GCR)

Build Status NPM version

A promise-based Node ORM/ActiveRecord library that can connect to MySQL, Postgres, and SQLite3. Allows chainable, raw or queueable queries.


Getting started

### new GCR(connection, [table], [options])
var GCR = require('grand-central-records');
 
var Model = new GCR({
    adapter: "mysql",
    host: "localhost",
    database: "test",
    username: "admin",
    password: "admin"
}, "users");
 
Model.find(8).then(function(users) {
    console.log(users[0].name);
}).catch(console.error);
 
Model.select(["name","address"]).where({admin: true})
.then(function(result) {
    result.forEach(function(user) { ... });
});

Creating a new instance of the GCR object creates a connection to a new database.

### model(table, [options])
  • table string — The name of the table the model is associated with.
  • options json — See above.

Multiple models can also be created from the same database.

var GCR = require('grand-central-records');
 
var db = new GCR({
    adapter: "mysql",
    host: "localhost",
    database: "test",
    username: "admin",
    password: "admin"
}, { verbose: true });
 
var User = db.model("users"),
    Project = db.model("projects");

Documentation

Getting started

Raw queries

Models

Other functions

Query methods

Postgres


Inspiration

Package Sidebar

Install

npm i grand-central-records

Weekly Downloads

40

Version

0.5.2

License

none

Last publish

Collaborators

  • maxprogram