Skip to content

Comment on SpahQL - A query language for Javascript objects

Comments

Interresting.

SQlike is another effort in the same direction. It provides a wide range of SQL features including joins. JavaScript tables are used as query language.

See http://www.thomasfrank.se/sqlike.html for an overview and http://www.thomasfrank.se/SQLike/ for examples.

    dataArray = [
    {firstName: "Paul", lastName: "Stele", age:35, salary:35000},
    ...
    ]

    dataArray2 = [
    {firstName: "Paul", lastName: "Stele", favColor:"green"},
    ...
    ]

    SQLike.q(
       {
           Select: ['*'],
           From: dataArray,
           Where: function(){return this.salary>50000},
           OrderBy: ['salary','|desc|']
       }
    )


    SQLike.q(
       {
           Select: ['*'],
           From: {t1:dataArray},
           NaturalJoin: {t2:dataArray2},
           Where:function(){return this.t1.firstName!='Vicki'}
       }
    )

This looks pretty handy for large datasets, to be sure.

SpahQL is definitely much lighter than that - the API is intended to be more jquery-like with a specific selector language, each selection returning a resultset object which then provides methods for subselections and modifications.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.