Live data from Hacker News

SpahQL - A query language for Javascript objects

angryamoeba.co.uk

1–10 of 37 posts

Re: SpahQL - A query language for Javascript objects

#2
have you considered adopting the jsonpath syntax?

it would be more javascripty and would be another implementation (or a superset) of jsonpath

http://goessner.net/articles/JsonPath/ http://code.google.com/p/jsonpath/ https://github.com/joshbuddy/jsonpath https://github.com/marianoguerra/jsonpath-scala

Re: SpahQL - A query language for Javascript objects

#3
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'}
       }
    )

Re: SpahQL - A query language for Javascript objects

#4

have you considered adopting the jsonpath syntax? it would be more javascripty and would be another implementation (or a superset) of jsonpath http://goessner.net/articles/JsonPath/ http://code.google.com/p/jsonpath/ https://github.com/joshbuddy/jsonpath https://github.com/marianoguerra/jsonpath-scala

Author here. I wanted to try something a little lighter than jsonpath and with a specific mode of (node collection|descent) that allowed set arithmetic to be the primary means of comparisons and assertions. This allowed me to obviate the need for scoped AND/OR structures and instead provide a broad range of assertion options using superset, subset, disjoint and joint set operations.

It's most certainly not perfect, but I had fun experimenting with it.

Re: SpahQL - A query language for Javascript objects

#6

have you considered adopting the jsonpath syntax? it would be more javascripty and would be another implementation (or a superset) of jsonpath http://goessner.net/articles/JsonPath/ http://code.google.com/p/jsonpath/ https://github.com/joshbuddy/jsonpath https://github.com/marianoguerra/jsonpath-scala

Author here. I wanted to try something a little lighter than jsonpath and with a specific mode of (node collection|descent) that allowed set arithmetic to be the primary means of comparisons and assertions. This allowed me to obviate the need for scoped AND/OR structures and instead provide a broad range of assertion options using superset, subset, disjoint and joint set operations. It's most certainly not perfect, b…

it's a nice project, and if it adds something extra then go for it :)

but sometimes I think jsonpath should be more visible and it's not, that's why I was trying to avoid fragmentation for the same solution. But as you said, it tries a different approach so it makes sense to use a different syntax.

Re: SpahQL - A query language for Javascript objects

#7
post #3

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…

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.

Re: SpahQL - A query language for Javascript objects

#8
I wish developers would stop copying SQL. It's like making fancy new languages, and then adding libraries that help you emulate COBOL. SQL is not the first, the last, or the best query language ever created, it's just the best marketed. It's not even properly relational, it's based on a series of shell scripts on multics for crying out loud!
Post reply on HN