Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wangzuo/arel
rails/arel in javascript
https://github.com/wangzuo/arel
activerecord javascript rails sql
Last synced: 3 months ago
JSON representation
rails/arel in javascript
- Host: GitHub
- URL: https://github.com/wangzuo/arel
- Owner: wangzuo
- License: mit
- Created: 2017-07-02T14:33:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-23T07:15:22.000Z (about 3 years ago)
- Last Synced: 2024-11-10T17:41:46.238Z (3 months ago)
- Topics: activerecord, javascript, rails, sql
- Language: JavaScript
- Homepage: https://wangzuo.github.io/arel
- Size: 245 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arel
[](https://www.npmjs.com/package/arel)
[](https://travis-ci.org/wangzuo/arel)
[](https://codecov.io/gh/wangzuo/arel)
[](https://github.com/prettier/prettier) [](https://greenkeeper.io/)[rails/arel](https://github.com/rails/arel) in javascript
### Installation
``` sh
npm i arel --save
```### Usage
``` javascript
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
``` javascript
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