Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staeco/iris-ql
User friendly API query language
https://github.com/staeco/iris-ql
Last synced: 16 days ago
JSON representation
User friendly API query language
- Host: GitHub
- URL: https://github.com/staeco/iris-ql
- Owner: staeco
- License: mit
- Created: 2019-06-26T17:25:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T14:33:18.000Z (over 1 year ago)
- Last Synced: 2024-09-27T09:08:31.744Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.1 MB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
User friendly API query language
# iris-ql [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][circle-image]][circle-url]
Iris is a safe and user-friendly query system for building flexible APIs with intuitive UIs to match. Built on top of [human-schema](https://github.com/staeco/human-schema) and Sequelize. Check out the docs folder to get started!
## Install
```
npm install iris-ql --save
```## Basic Example
```js
import { Query } from 'iris-ql'// Find all crimes by criminal 1 or 2 after 2017
const query = new Query({
limit: 100,
filters: {
createdAt: { $gt: '2017-05-13T00:00:00.000Z' },
$or: [
{ name: 'Criminal 1' },
{ name: 'Criminal 2' }
]
},
orderings: [
{ value: { field: 'createdAt' }, direction: 'desc' }
]
}, { model: crime })const results = await query.execute()
```## Analytics Example
```js
import { AnalyticsQuery } from 'iris-ql'// get a time series of all 911 calls
const crimeTimeSeries = new AnalyticsQuery({
filters: {
data: {
receivedAt: { $ne: null }
}
},
aggregations: [
{ value: { function: 'count' }, alias: 'total' },
{
alias: 'day',
value: {
function: 'bucket',
arguments: [
'day',
{ field: 'data.receivedAt' }
]
}
}
],
orderings: [
{ value: { field: 'day' }, direction: 'desc' }
],
groupings: [
{ field: 'day' }
]
}, { model: emergencyCall })const results = await crimeTimeSeries.execute()
/*
[
{ total: 20, day: '2017-05-13T00:00:00.000Z' },
{ total: 3, day: '2017-05-14T00:00:00.000Z' },
{ total: 2, day: '2017-05-15T00:00:00.000Z' }
]
*/
```## DB Support
Currently only works with Postgres 12+. Some features and specific functions may require newer versions. In the future, the database layer will be broken out into adapters and multiple stores will be supported.
[downloads-image]: http://img.shields.io/npm/dm/iris-ql.svg
[npm-url]: https://npmjs.org/package/iris-ql
[npm-image]: http://img.shields.io/npm/v/iris-ql.svg[circle-url]: https://circleci.com/gh/staeco/iris-ql
[circle-image]: https://circleci.com/gh/staeco/iris-ql.svg?style=svg