0.1.1 • Published 7 years ago

ilula.js v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

iLula.js

PLEASE DO NOT USE, STILL UNDERS CONSTRUCTION

build statusversionreleasedlicence
Travis (.org) branchnpm (tag)release statusNpmLicense

A extensible logic engine that allows constructing of complex analyics queries by translating database syntax using a pure JavaScript fluid API.

Install

With NPM

npm install ilula.js

From source

git clone https://github.com/personation/iLula.js.git
cd iLula.js
npm install
npm test
npm run build

Usage

    // ES5
    const i = require('ilula.js')
    // ES6
    import i from 'ilula.js'

    // initialize an instance
    const expr = i()

    // Build expressions
    expr.int(2).plus(2).mul(4) // => save (2 + 2) * 4 expression in overload state of instance
    expr.code // => print expression (2 + 2) * 4
    expr.data // => evaluate expression (2 + 2) * 4

    ////////////////////////////////////////////
    // Simple query example with in-memory table

    // in-memory table
    const table = [
        {name: 'Pumpkin', surname: 'Patch', age: 34},
        {name: 'Paul', surname: 'NewMan', age: 46},
        {name: '', surname: '', age: }
    ]
    // simple projection query
    i()
    .return('name', 'surname', H().ref('age').div(2))
    .from(table)
    .data()
    .then(result => {
        console.log(result)
    })
    .catch(ErrHandler)

    //////////////////////////////////////////////////////
    // Simple query with Aggregations from external source

    // import db client lib
    import json from '@personation/json'

    // bind db client to logic engine
    i().use(json({
        ... DBclient_configuration
    }))

    // query db client
    i()
    .return('country')
    .sum('population').as('population')
    .from('census_stats')
    .data()
    .then(result => {
        console.log(result)
    })
    .catch(ErrHandler)

    //////////////////////////////
    // Simple nested query example
    i()
    .return('country')
    .sum('population').as('population')
    .from(
        i().
        return(H().ref('country_names').as('country'), 'population')
        .from([
            {name: 'Pumpkin', surname: 'Patch', age: 34},
            {name: 'Paul', surname: 'NewMan', age: 46},
            {name: '', surname: '', age: }
        ])
    )
    .data()
    .then(result => {
        console.log(result)
    })
    .catch(ErrHandler)

API

Website with a complete API breakdown is coming soon.

License

The MIT, Version 2.0. For more information, see the accompanying LICENSE file.

0.1.1

7 years ago

0.1.0

7 years ago