https://github.com/xkjyeah/squeal
https://github.com/xkjyeah/squeal
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/xkjyeah/squeal
- Owner: xkjyeah
- Created: 2016-09-12T12:35:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-12T15:09:37.000Z (over 8 years ago)
- Last Synced: 2025-01-01T22:29:10.033Z (6 months ago)
- Language: TypeScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Squeal
------SQL is broken. It's verbose and unintuitive to the modern-day programmer.
Filtering by the total value of an accounting transaction
=========================================================### In Javascript:
```js
JournalEntry.find(
(journalEntry) => _.sumBy(journalEntry.lineItems,
(lineItem) => lineItem.debit) > 10000
)
```### Doing the same in SQL
```sql
SELECT
*
FROM JournalEntries
WHERE (SELECT SUM(debit)
FROM LineItems
WHERE LineItems.JournalEntryId = JournalEntries.ID) > 10000
```### Doing the same in Sequelize.js
Impossible### Doing the same in Knex
Not very different from doing it in SQL### How Squeal tries to solve it
```js
JournalEntry.where(
(journalEntry) => journalEntry.fetch('lineItems').col('debit').sum() > 1000
)
```## TODO:
1. Clean up API
2. Test cases
3. Optimizations using `WITH` clauses