0.0.8 • Published 4 months ago

gaql v0.0.8

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
4 months ago

gaql

npm agpl

gaql is a query language, comprising a JSON-compiler and resolver. It is extensible to support any query and common queries are published with gaql for general operations involving math, logic, time, etc. See example usages in the unit-tests,

import gaql from 'gaql'
import * as core from 'gaql/src/queries/core.js'
import * as logic from 'gaql/src/queries/logic.js'
import * as transform from 'gaql/src/queries/transform.js'
import * as aggregate from 'gaql/src/queries/aggregate.js'

const q = gaql([ core, logic, transform, aggregate ])

const winners = await q
  .expr([
    { id: 123, wins: 13, losses: 5, name: 'jim' },
    { id: 456, wins: 16, losses: 2, name: 'jen' },
    { id: 789, wins: 8, losses: 10, name: 'jon' }])
  .filter(user => user('wins').gt(user('losses')))
  .orderBy(q.desc('wins'))
  .map(user => user('name'))
  .run()

console.log(winners) // ['jen', 'jim']

gaql is modelled after the ReQL query language used by RethinkDB and, specifically, its interface is modelled after the excellent rethinkdb-ts javascript driver.

gaql provides excellent support for resolving complex operations in a small and portable module. A few short-comings listed below are okay for my own usage now, and could be improved later with updates,

  • Error handling at the JSON-compiler could be improved. If the user chains a "list" operation to an "integer" result, the compiler will not detect the error before it occurs at runtime,
  • Error handling at the resolver could be improved. Error messages could show specific parts of a query that cause the error,
  • JSON instructions are not heavily-optimized. Small example; "concatMap" appears in the JSON instructions, rather than, say, a mapped-integer.
0.0.8

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

5 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago