JavaScript HTML
Switch branches/tags
Nothing to show
Latest commit b8ec101 Jul 20, 2017 @wangzuo update sqlstring test
Permalink
Failed to load latest commit information.
repl built in FakeRecord Jul 8, 2017
src update sqlstring test Jul 20, 2017
.babelrc update build Jul 7, 2017
.gitignore add build Jul 7, 2017
.npmignore order() fix Jul 10, 2017
.travis.yml fix ci Jul 7, 2017
LICENSE Initial commit Jul 2, 2017
README.md fix examples in test Jul 13, 2017
_config.yml Set theme jekyll-theme-minimal Jul 15, 2017
index.js add build Jul 7, 2017
package.json 0.1.5 Jul 20, 2017
test.js update test.js Jul 15, 2017
webpack.config.js built in FakeRecord Jul 8, 2017
yarn.lock fix hash Jul 9, 2017

README.md

Arel

Build Status codecov styled with prettier

rails/arel in javascript

Installation

npm i arel --save

Usage

import * as Arel from 'arel'; // es6
// const Arel = require('arel');

const users = new Arel.Table('users');
const query = users.project(Arel.sql('*'));
query.toSql(); // => SELECT * FROM "users"

More examples

users.project(users.column('id'))
// => SELECT "users"."id" FROM "users"

users.where(users.column('name').eq('amy'))
// => SELECT FROM "users" WHERE "users"."name" = 'amy'

const photos = new Arel.Table('photos');
users.join(photos).on(users.column('id').eq(photos.column('user_id')))
// => SELECT FROM "users" INNER JOIN "photos" ON "users"."id" = "photos"."user_id"

License

MIT