Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k-components/mongo-aql
An extensible SQL generation library for JavaScript with a focus on introspectibility
https://github.com/k-components/mongo-aql
Last synced: 3 months ago
JSON representation
An extensible SQL generation library for JavaScript with a focus on introspectibility
- Host: GitHub
- URL: https://github.com/k-components/mongo-aql
- Owner: k-components
- Fork: true (goodybag/mongo-sql)
- Created: 2015-11-13T20:41:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T06:28:29.000Z (almost 2 years ago)
- Last Synced: 2024-07-10T10:31:10.984Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 660 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-arangodb - mongo-aql - A mongo-like interface for aql generation. (Uncategorized / Uncategorized)
README
# mongo-aql - JSON to AQL
##Install
```
$ npm i mongo-aql --save
```##Usage
```javascript
var builder = require('mongo-aql');var q = {
foo: { bar: 'baz', bar2: 'baz2' },
"$limit": 10,
"$skip": 100,
"$orderby": { name: 1, name2: 1 },
"@city": "cities",
"@like": "likes"
}var res = builder('users', q);
```
Result:
```js
{ query: 'FOR u IN users FILTER u.foo.bar == @v0 && u.foo.bar2 == @v1 LIMIT @v2, @v3 SORT u.name ASC, u.name2 ASC LET c0 = DOCUMENT(@@v4, u.city) LET c1 = DOCUMENT(@@v5, u.like) RETURN merge(u, { city: c0 }, { like: c1 })',
values:
{ v0: 'baz',
v1: 'baz2',
v2: 100,
v3: 10,
'@v4': 'cities',
'@v5': 'likes' },
}```
##License
BSD