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: about 2 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 (almost 3 years ago)
- Last Synced: 2024-11-10T17:41:46.238Z (2 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
[![npm](https://img.shields.io/npm/v/arel.svg)](https://www.npmjs.com/package/arel)
[![Build Status](https://travis-ci.org/wangzuo/arel.svg?branch=master)](https://travis-ci.org/wangzuo/arel)
[![codecov](https://codecov.io/gh/wangzuo/arel/branch/master/graph/badge.svg)](https://codecov.io/gh/wangzuo/arel)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Greenkeeper badge](https://badges.greenkeeper.io/wangzuo/arel.svg)](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