[nodejs] performing SQL queries on JSON - pure JavaScript LINQ implementation running in browser + node

886 views
Skip to first unread message

Marak Squires

unread,
May 4, 2010, 9:49:30 PM5/4/10
to nod...@googlegroups.com
Hello dear internet friends!

i have freed some code from codeplex and got Microsoft's LINQ working nicely in the browser and in node. 

LINQ (http://en.wikipedia.org/wiki/Language_Integrated_Query) is pretty well known in .NET land, but I think it could really help out in JavaScript land as its power lays in the ability to perform queries against JSON. i've tried json-path and json-query in the past and did not like.

i know microsoft is generally frowned upon, but i've remove the fat, centralized the documentation, created a github, and ported it to node. enjoy!

http://github.com/marak/JSLINQ - for code and examples


-Marak


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Scott Taylor

unread,
May 4, 2010, 10:16:43 PM5/4/10
to nod...@googlegroups.com
On May 4, 2010, at 9:49 PM, Marak Squires wrote:

Hello dear internet friends!

i have freed some code from codeplex and got Microsoft's LINQ working nicely in the browser and in node. 

LINQ (http://en.wikipedia.org/wiki/Language_Integrated_Query) is pretty well known in .NET land, but I think it could really help out in JavaScript land as its power lays in the ability to perform queries against JSON. i've tried json-path and json-query in the past and did not like.

i know microsoft is generally frowned upon, but i've remove the fat, centralized the documentation, created a github, and ported it to node. enjoy!

Not their research division!

I've never really taken the time to fully grok linq.  I don't know a ton of haskell, but I guess it's some combination of haskell's list compressions & sql.  What I don't understand is exactly _how_ it integrates into my current tool set.  Does it generate sql, or assume that all of the data is already in memory?

Interesting stuff, either way.

Scott

Marak Squires

unread,
May 4, 2010, 10:26:46 PM5/4/10
to nod...@googlegroups.com
 What I don't understand is exactly _how_ it integrates into my current tool set.  Does it generate sql, or assume that all of the data is already in memory?

In JavaScript land, you use JSLINQ() or JSLINQ.Exec() to perform queries against JSON data in memory, basically if you need to perform any query operation on JSON data that is in memory. This because especially useful when you start thinking of things like browser-side templating, flat-file json databases (like node-dirty), or offline storage.

There are some very clear examples of usage in the links I've provided, check them out!

-Marak

Ricardo Tomasi

unread,
May 5, 2010, 12:04:15 AM5/5/10
to nodejs
Hi Marak,

Are there any advantages in jslinq over standard map/filter/sort
functions?

cheers,
Ricardo

On May 4, 11:26 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> * What I don't understand is exactly _how_ it integrates into my current
> tool set.  Does it generate sql, or assume that all of the data is already
> in memory?*
> *
> *
> *In JavaScript land, you use JSLINQ() or JSLINQ.Exec() to perform queries
> against JSON data in memory, basically if you need to perform any query
> operation on JSON data that is in memory. This because especially useful
> when you start thinking of things like browser-side templating, flat-file
> json databases (like node-dirty), or offline storage.*
> *
> *
> *There are some very clear examples of usage in the links I've provided,
> check them out!*
> *
> *
> *-Marak
> *
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nodejs?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/nodejs?hl=en.

Marak Squires

unread,
May 5, 2010, 12:34:20 AM5/5/10
to nod...@googlegroups.com
Ricardo - 

There are many advantages, to name a few:

JSLINQ has a easy to use syntax and is fluent, aka chainable (think jQuery)

JSLINQ has many many other SQL methods, such as JOIN, UNION, RANGE, DISTINCT, COUNT, etc. You can see the full JS API @ http://maraksquires.com/JSLINQ/api.html...must make more demos

LINQ is a well established language used by many M$ fanboys

also....there has been talking about getting IEnumerable to work in JSLINQ for processing large datasets..... gotta write the benchmarks first :-D

-Marak 

Karl Tiedt

unread,
May 5, 2010, 12:09:15 AM5/5/10
to nod...@googlegroups.com
I would have to guess the addition of Query support...

-Karl Tiedt

Jan Schütze

unread,
May 5, 2010, 3:54:26 AM5/5/10
to nod...@googlegroups.com
Hello Marak,

we have been using http://taffydb.com for some time at work. At first
sight it looked pretty helpful and seemed to be good for some tasks.

But we ended up to remove the magic client side db again, because it
is way slower then writing pure javascript and gives on the opposite
site, just a little "value".

See for instance the method:

return JSLINQ(Samples.People).All(function (item, index) {
return "Chris" == item.FirstName;
}

Is pretty much the same like:

return Samples.People.filter(item) {
return "Chris" == item.FirstName;
}

Same goes for orderBy:

var numbers = [4, 2, 5, 1, 3];
numbers.sort(function(a, b) {
return a - b;
});
print(numbers);

Actually such library as TaffyDB and yours *just* (please do not take
it personal) wraps the existing array (which is very fast implemented)
with an extra object representation (JSLINQ or Taffy) and offers the
native Javascript-Functions with a different name.

That's why we ended up removing TaffyDB and using Javascript array
functions. A searching in TaffyDB was like 80x slower (160ms vs 2ms)
in a Firefox, then using native Javascript with same expressiveness.

Regards,
Jan
--

http://dracoblue.net

Marak Squires

unread,
May 5, 2010, 4:24:14 AM5/5/10
to nod...@googlegroups.com
Jan -

Thanks for taking a look at the lib.

i have no idea how Taffy is implemented, JSLINQ is very small and will work both server-side and client-side JS

if you look at the code (http://github.com/Marak/JSLINQ/blob/master/lib/JSLINQ.js) you'll see that things like sorting, are infact done by Array.sort(). i seem to remember map and filter not being fully implemented cross browser, but there's no reason why we couldn't replace the current calls with map() and filter() if they are available (especially in node since we know they are available) there might be some good code in http://documentcloud.github.com/underscore/ for doing some of this

the examples you have shown are simple queries. using raw js code quickly becomes unmanageable when you start creating complex , nested operations. 

i definitely want the highest performance available, so i think the best course of action would be to build some benchmarks so we can properly test the side on both the browser and the server. once we have these, we can start testing different solutions to determine what is optimal.

based on conversations i've been having, i think it might be possible to increase performance for larger datasets by porting http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx 

anyway, thanks for the input. please feel free to create issues on the github or fork the release and apply your own patches. i do accept and encourage pull requests!

-marak


2010/5/5 Jan Schütze <Ja...@dracoblue.de>

Elijah Insua

unread,
May 5, 2010, 3:17:27 PM5/5/10
to nod...@googlegroups.com
Nice work Marak, do you ever sleep?

-- Elijah

Marak Squires

unread,
May 5, 2010, 3:20:07 PM5/5/10
to nod...@googlegroups.com
I knew I forgot to do something last night :-(

There is a ton of work that still needs to be done to this lib, but I think we've got a great start.

Akzhan Abdulin

unread,
May 5, 2010, 3:42:51 PM5/5/10
to nod...@googlegroups.com
I know about yet another LINQ implementation, - http://www.hugoware.net/Projects/jLinq


2010/5/5 Marak Squires <marak....@gmail.com>

Karl Guertin

unread,
May 5, 2010, 3:55:20 PM5/5/10
to nod...@googlegroups.com
On Wed, May 5, 2010 at 3:42 PM, Akzhan Abdulin <akzhan....@gmail.com> wrote:
> I know about yet another LINQ implementation,
> - http://www.hugoware.net/Projects/jLinq

I know of another:

http://jsinq.codeplex.com/

Marak Squires

unread,
May 5, 2010, 4:04:40 PM5/5/10
to nod...@googlegroups.com
JSINQ is actually really close to implementation i want. i just dont like the syntax of jsinq (which could be fixed), but the size is really really big. i'd like to get the full api working (as jsinq does), but with a lot of less code.....and the cleaner syntax

-Marak

Dean Landolt

unread,
May 5, 2010, 5:39:56 PM5/5/10
to nod...@googlegroups.com
On Tue, May 4, 2010 at 9:49 PM, Marak Squires <marak....@gmail.com> wrote:
Hello dear internet friends!

i have freed some code from codeplex and got Microsoft's LINQ working nicely in the browser and in node. 

LINQ (http://en.wikipedia.org/wiki/Language_Integrated_Query) is pretty well known in .NET land, but I think it could really help out in JavaScript land as its power lays in the ability to perform queries against JSON. i've tried json-path and json-query in the past and did not like.


I'm also not a huge fan of json-query's syntax but there's definitely value in the declarative approach. Kris Zyp's successor to json-query is resource-query [1] -- I think you'll find it a little more palatable. It's much more compact and familiar than both json-query and LINQ and almost as expressive. Here are the examples you've got on github compared to equivalent resource queries:


simple Select:

var sample = JSLINQ(sampleData).
  Select(function (item) {return item.FirstName;});

resource-query: "select(FirstName)"


simple Select with OrderBy

 var sample = JSLINQ(sampleData).
  Select(function (item) {return item.FirstName;}).
  OrderBy(function (item) {return item;});

resource-query: "sort(FirstName)&select(FirstName)"

more complex select/sorts, just for good measure:

sort descending: "sort(-FirstName)&select(FirstName)"

multisort, multiselect: "sort(FirstName,-LastName)&select(FirstName,LastName)"


simple Where

var sample = JSLINQ(sampleData).Where(function (item) {return item.FirstName == "Chris";});

resource-query: "FirstName=Chris"


Other types of calls are supported: for instance "in" and "slice" -- and for comparisons you can use other comparators (<, >=, != ... ). And these two things -- calls and comparisons -- are really the only primitives you'll typically need.

Right now the resource-query module is bundled in the perstore [2] package it could be put somewhere (perhaps the commonjs-utils [3] package). But if you choose to use it with perstore you'll get some added benefits -- for starters you can use the persistent-memory store and get a node-dirty-like experience plus resource-query. And, of course, you could always run JSLINQ operations on top of the result set -- the best of both worlds. Oh yeah -- perstore "stores" support resource-query (or some reasonable subset) which allows you to use the same syntax to efficiently query mongo and sql and your raw memory store all the same. It's relatively easy to compile resource-query down into your query language of choice to push to your data store of choice -- that's a pretty big win.

If you choose to use it with pintura [4] (meaning, over HTTP) the resource queries are simply the query component of your urls (notice how the syntax is url-safe: try that with LINQ :) so your queries would look like this:


And your results are all streamed back asynchronously (yes, for the last time -- JSGI does streaming, async, and streaming async).

Getting started with either perstore or pintura on node is simple with Kris' new nodules [5] package -- but I'll be happy to walk anyone through it. I just wanted to make everyone aware of resource-query -- it does most of what you'd need out of JSLINQ and has some other big wins, plus syntactically it's as simple as possible and url-safe. Give it a spin -- I'd love to hear if and how it falls flat...

Dean


Marak Squires

unread,
May 5, 2010, 6:19:40 PM5/5/10
to nod...@googlegroups.com
Dean -

Thank you for the detailed response. I'm still experimenting with JSON based query languages, always good to know there are options available. I haven't had the chance to really dive into doing a lot of complicated JSON queries, so far most of it has been fairly simple stuff. 

a couple of quick questions if you don't mind:

does resource-query work browser-side and cross-browser?

does / will resource-query support most of these methods? http://maraksquires.com/JSLINQ/api.html (more specifically, im particularly interested in JOIN and GroupBy)

it seems you also have a whole packaged solution, is it possible to just one some of these pieces?

are there any pages where i play around with the syntax in an interactive console? something like http://maraksquires.com/JSLINQ/

and a few comments : 

i do like the idea of having the queries be URL safe, but in the context of what i'm doing thats a bit irrelevant.

i do kinda like the syntax that Linq uses, but more importantly Linq is pretty well known in the .net community. pretty much anyone who does .net work with data should know about Linq. it seems kris is inventing his own syntax? this isn't nessarlity a bad thing, but there is something to be said on language design.

-Marak

Dean Landolt

unread,
May 5, 2010, 7:19:42 PM5/5/10
to nod...@googlegroups.com
On Wed, May 5, 2010 at 6:19 PM, Marak Squires <marak....@gmail.com> wrote:
Dean -

Thank you for the detailed response.


No problem -- awesome job on this BTW! I just wanted to point out lighter weight (syntax-wise) alternative...or complement, depending on how you look at it.
 

I'm still experimenting with JSON based query languages, always good to know there are options available. I haven't had the chance to really dive into doing a lot of complicated JSON queries, so far most of it has been fairly simple stuff. 

a couple of quick questions if you don't mind:

does resource-query work browser-side and cross-browser?


It should be able to be adapted -- it's completely dep-free. I haven't tried it in the browser but only thing that jumps out at me from a cross-browser standpoint would be arrays expected to have a forEach -- but that's obviously easy to work around.
 

does / will resource-query support most of these methods? http://maraksquires.com/JSLINQ/api.html (more specifically, im particularly interested in JOIN and GroupBy)


I see you don't have these yet either :)


Grouping is also of particular interest to me as well -- I'd love to find a syntax for grouping that works (and can be optimized for, for instance, sql and mongo query compilation). Sacrifices would have to be made but I'm confident there are some primitives that would give us what we need.

As I see it there are three levels to efficient query handling -- what can be compiled and pushed down to datastore to handle natively (e.g. comparisons), what can be handled reasonably efficiently in the streamed response (e.g. filters) and what requires full buffering (e.g. reverse). And of course this will depend on your store's query support. I'd like to go deeper into what I mean by this but it's a bit OT and irrelevant when comparing apples-to-apples with JSLINQ except to say it one of the reasons I think these two techniques are complementary is that resource-query could server as an excellent source for arrays to LINQ over (e.g. database result sets) -- you may not always want to keep your whole db in memory.
 


it seems you also have a whole packaged solution, is it possible to just one some of these pieces?


Yes, it should be possible to just use resource-query itself, or any part thereof (just the parseQuery function, for instance, to get a parsed query object that you can do what you want with -- like compile alternate queries with). Does JSLINQ offer anything like an AST? That'd be really cool.
 


are there any pages where i play around with the syntax in an interactive console? something like http://maraksquires.com/JSLINQ/


No but that's a damn fine idea. I'll push your example data set to somewhere public so that you can play around with it like God intended -- right in the url :)

 

and a few comments : 

i do like the idea of having the queries be URL safe, but in the context of what i'm doing thats a bit irrelevant.


Sure enough -- just a bonus.

 

i do kinda like the syntax that Linq uses, but more importantly Linq is pretty well known in the .net community.


You like LINQ's syntax? I'd always considered it a necessary evil. The chaining is great but its still so imperative. It's just not something I'd trust to be built on the fly based on some client side form, for example. That's where something like resource-query shines. If you're lazy and you're down with Dojo you can use the JsonRestStore to build resource-query for you.

 
pretty much anyone who does .net work with data should know about Linq.


But what does that have to do with javascript?! As far as I can tell I'm one of the few people around these parts that do use LINQ regularly (I work for a .NET shop and try to abuse LINQ every time I'm forced to crack open Visual Studio). Still, after quite a bit of usage I still don't fully grep it -- and that's my real gripe with it -- it's very much like magic (though not as pretty).

 
it seems kris is inventing his own syntax? this isn't nessarlity a bad thing, but there is something to be said on language design.


Ah, but to me that's the fundamental difference between the two approaches -- LINQ is like a full on language -- resource-query is a reasonably lightweight extension to standard querystring syntax.


Thanks for the comments. I'll get something for you to poke around at. Looking at your api docs and code make me think a lot of the LINQ stuff could be supported in one way or another. And for that which can't, the ability to throw some JSLINQ on top of a resource-query result is pretty awesome!

Akzhan Abdulin

unread,
May 6, 2010, 6:53:59 AM5/6/10
to nod...@googlegroups.com
There is big difference - LINQ has lazy approach to work with data. Your implementation works immediately with data.

2010/5/5 Marak Squires <marak....@gmail.com>
Message has been deleted

alexis

unread,
May 6, 2010, 7:14:07 AM5/6/10
to nodejs
Dean,

I'm looking for a declarative language like jsonpath or jsonquery in
order to bind javascript objects (it's a bit more complicated, since
it's restfull resources in fact) to ui widgets.

I'm using kris zyp implementation of jsonquery, having modified it in
order to get values *and* absolutes paths when i execute a query.

By absolutes paths, i mean :

JSONQuery("store.book[?price<10].title").paths -->
["store.book[0].title", "store.book[1].title", "store.book[3].title"]

I need absolutes paths to make read/write bindinds. Of course queries
like "store.book[0][=title + " : " + author] are readonly.

What i'm doing is a bit like what Microsoft is doing with jQuery
(http://forum.jquery.com/topic/proposal-for-adding-data-linking-to-
jquery) and a bit like what Kris Zyp seems to have done with
persevere.

I do stuff like :

var q = createAQuery("/store/store.book[?price<10].title"); //
createAQuery is not the real function name
q.onChange(function(newVal, oldVal) {
//Do Stuff
});
q.onError(function(errors) {
//Do Stuff with errors
});

---

var q = createAQuery("/store/store.book[?price<10").attr("title", "my
new title");

---

var title = createAQuery("/store/store.book[?price<10").attr("title");
var title = createAQuery("/store/store.book[?price<10").value().title;

---

var q = createAQuery("/store/store.book[?price<10]");
q.each(function(value, itemQuery, index) {
if (value.price > 5) {
itemQuery.attr("buyit", true);
}
});

---

As IQueryable in Linq, q variables are *lazy* with datas.
So i'm really interested with resource-queries, do you have more
documentation on it ?

On 6 mai, 01:19, Dean Landolt <d...@deanlandolt.com> wrote:
> On Wed, May 5, 2010 at 6:19 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> > Dean -
>
> > Thank you for the detailed response.
>
> No problem -- awesome job on this BTW! I just wanted to point out lighter
> weight (syntax-wise) alternative...or complement, depending on how you look
> at it.
>
> I'm still experimenting with JSON based query languages, always good to know
>
> > there are options available. I haven't had the chance to really dive into
> > doing a lot of complicated JSON queries, so far most of it has been fairly
> > simple stuff.
>
> > *a couple of quick questions if you don't mind:*
>
> > does resource-query work browser-side and cross-browser?
>
> It should be able to be adapted -- it's completely dep-free. I haven't tried
> it in the browser but only thing that jumps out at me from a cross-browser
> standpoint would be arrays expected to have a forEach -- but that's
> obviously easy to work around.
>
>
>
> > does / will resource-query support most of these methods?
> >http://maraksquires.com/JSLINQ/api.html(more specifically,
> > im particularly interested in JOIN and GroupBy)
>
> I see you don't have these yet either :)
>
> Grouping is also of particular interest to me as well -- I'd love to find a
> syntax for grouping that works (and can be optimized for, for instance, sql
> and mongo query compilation). Sacrifices would have to be made but I'm
> confident there are some primitives that would give us what we need.
>
> As I see it there are three levels to efficient query handling -- what can
> be compiled and pushed down to datastore to handle natively (e.g.
> comparisons), what can be handled reasonably efficiently in the streamed
> response (e.g. filters) and what requires full buffering (e.g. reverse). And
> of course this will depend on your store's query support. I'd like to go
> deeper into what I mean by this but it's a bit OT and irrelevant when
> comparing apples-to-apples with JSLINQ except to say it one of the reasons I
> think these two techniques are complementary is that resource-query
> *could* server
> as an excellent *source* for arrays to LINQ over (e.g. database result sets)
> -- you may not *always *want to keep your whole db in memory.
>
> > it seems you also have a whole packaged solution, is it possible to just
> > one some of these pieces?
>
> Yes, it should be possible to just use *resource-query* itself, or any part
> thereof (just the parseQuery function, for instance, to get a parsed query
> object that you can do what you want with -- like compile alternate queries
> with). Does JSLINQ offer anything like an AST? That'd be really cool.
>
> > are there any pages where i play around with the syntax in an interactive
> > console? something likehttp://maraksquires.com/JSLINQ/
>
> No but that's a damn fine idea. I'll push your example data set to somewhere
> public so that you can play around with it like God intended -- right in the
> url :)
>
>
>
> > *and a few comments : *
>
> > i do like the idea of having the queries be URL safe, but in the context of
> > what i'm doing thats a bit irrelevant.
>
> Sure enough -- just a bonus.
>
>
>
> > i do kinda like the syntax that Linq uses, but more importantly Linq is
> > pretty well known in the .net community.
>
> You *like* LINQ's syntax? I'd always considered it a necessary evil. The
> chaining is great but its still so imperative. It's just not something I'd
> trust to be built on the fly based on some client side form, for example.
> That's where something like resource-query shines. If you're lazy and you're
> down with Dojo you can use the JsonRestStore to build resource-query for
> you.
>
> > pretty much anyone who does .net work with data should know about Linq.
>
> But what does that have to do with javascript?! As far as I can tell I'm one
> of the *few* people around these parts that *do* use LINQ regularly (I work
> for a .NET shop and try to abuse LINQ every time I'm forced to crack open
> Visual Studio). Still, after quite a bit of usage I *still* don't fully grep
> it -- and that's my real gripe with it -- it's very much like magic (though
> not as pretty).
>
> > it seems kris is inventing his own syntax? this isn't nessarlity a bad
> > thing, but there is something to be said on language design.
>
> Ah, but to me that's the fundamental difference between the two approaches
> -- LINQ *is* like a full on language -- resource-query is a reasonably
> lightweight extension to standard querystring syntax.
>
> Thanks for the comments. I'll get something for you to poke around at.
> Looking at your api docs and code make me think a lot of the LINQ stuff
> could be supported in one way or another. And for that which can't, the
> ability to throw some JSLINQ on top of a resource-query result is pretty
> awesome!
>
>
>
>
>
> > -Marak
>
> > On Wed, May 5, 2010 at 5:39 PM, Dean Landolt <d...@deanlandolt.com> wrote:
>
> >> On Tue, May 4, 2010 at 9:49 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> >>> Hello dear internet friends!
>
> >>> i have freed some code from codeplex and got Microsoft's LINQ working
> >>> nicely in the browser and in node.
>
> >>> LINQ (http://en.wikipedia.org/wiki/Language_Integrated_Query) is pretty
> >>> well known in .NET land, but I think it could really help out in JavaScript
> >>> land as its power lays in the ability to perform queries against JSON. i've
> >>> tried json-path and json-query in the past and did not like.
>
> >> I'm also not a huge fan of json-query's syntax but there's definitely
> >> value in the declarative approach. Kris Zyp's successor to json-query is
> >> resource-query [1] -- I think you'll find it a little more palatable. It's
> >> much more compact and familiar than both json-query and LINQ and almost as
> >> expressive. Here are the examples you've got on github compared
> >> to equivalent resource queries:
>
> >> *simple Select*:
>
> >> var sample = JSLINQ(sampleData).
> >>   Select(function (item) {return item.FirstName;});
>
> >> *resource-query:* "select(FirstName)"
>
> >> *simple Select with OrderBy*
>
> >>  var sample = JSLINQ(sampleData).
> >>   Select(function (item) {return item.FirstName;}).
> >>   OrderBy(function (item) {return item;});
>
> >> *resource-query:* "sort(FirstName)&select(FirstName)"
>
> >> *more complex select/sorts, just for good measure:*
>
> >> *sort descending:* "sort(-FirstName)&select(FirstName)"
>
> >> *multisort, multiselect*:
> >> "sort(FirstName,-LastName)&select(FirstName,LastName)"
>
> >> *simple Where*
>
> >> var sample = JSLINQ(sampleData).Where(function (item) {return
> >> item.FirstName == "Chris";});
>
> >> *resource-query:* "FirstName=Chris"
>
> >> Other types of *calls* are supported: for instance "in" and "slice" --
> >> and for comparisons you can use other comparators (<, >=, != ... ). And
> >> these two things -- calls and comparisons -- are really the only primitives
> >> you'll typically need.
>
> >> Right now the resource-query module is bundled in the perstore [2] package
> >> it could be put somewhere (perhaps the commonjs-utils [3] package). But if
> >> you choose to use it *with* perstore you'll get some added benefits --
> >> for starters you can use the persistent-memory store and get a
> >> node-dirty-like experience plus resource-query. And, of course, you could
> >> always run JSLINQ operations on top of the result set -- the best of both
> >> worlds. Oh yeah -- perstore "stores" support resource-query (or some
> >> reasonable subset) which allows you to use the same syntax to efficiently
> >> query mongo and sql and your raw memory store all the same. It's relatively
> >> easy to compile resource-query down into your query language of choice to
> >> push to your data store of choice -- that's a pretty big win.
>
> >> If you choose to use it with pintura [4] (meaning, over HTTP) the resource
> >> queries are simply the query component of your urls (notice how the syntax
> >> is url-safe: try that with LINQ :) so your queries would look like this:
>
> >>http://localhost:8080/book/?sort(FirstName,-LastName)&select(FirstNam...)
>
> >> And your results are all streamed back asynchronously (yes, for the last
> >> time -- JSGI does streaming, async, and streaming async).
>
> >> Getting started with either perstore or pintura on node is simple with
> >> Kris' new nodules [5] package -- but I'll be happy to walk anyone through
> >> it. I just wanted to make everyone aware of resource-query -- it does most
> >> of what you'd need out of JSLINQ and has some other big wins, plus
> >> syntactically it's as simple as possible and url-safe. Give it a spin -- I'd
> >> love to hear if and how it falls flat...
>
> >> Dean
>
> >> [1]http://github.com/kriszyp/perstore/blob/master/lib/resource-query.js
> >> [2]http://github.com/kriszyp/perstore/
> >> [3]http://github.com/kriszyp/commonjs-utils
> >> [4]http://github.com/kriszyp/pintura/
> >> [5]http://github.com/kriszyp/nodules
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "nodejs" group.
> >> To post to this group, send email to nod...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/nodejs?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nodejs?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email ...
>
> plus de détails »

Dean Landolt

unread,
May 6, 2010, 12:04:35 PM5/6/10
to nod...@googlegroups.com
On Thu, May 6, 2010 at 7:14 AM, alexis <acoud...@gmail.com> wrote:
Dean,

I'm looking for a declarative language like jsonpath or jsonquery in
order to bind javascript objects (it's a bit more complicated, since
it's restfull resources in fact) to ui widgets.

I'm using kris zyp implementation of jsonquery, having modified it in
order to get values *and* absolutes paths when i execute a query.

By absolutes paths, i mean :

JSONQuery("store.book[?price<10].title").paths -->
["store.book[0].title", "store.book[1].title", "store.book[3].title"]

I need absolutes paths to make read/write bindinds. Of course queries
like "store.book[0][=title + " : " + author] are readonly.

That's a cool idea. You're obviously heavily reliant on paths, which is fine, but resource-query probably isn't for you. When I said "successor" I just meant resource-query is json-query's successor in persevere -- it serves the same purpose. That doesn't mean json-query and json-path are no longer useful -- and it looks like you've found a really great use.
 

What i'm doing is a bit like what Microsoft is doing with jQuery
(http://forum.jquery.com/topic/proposal-for-adding-data-linking-to-
jquery) and a bit like what Kris Zyp seems to have done with
persevere.

Yeah, reactive bindings are all the rage. Should simplify and DRY up a lot of UI code.
I have a few pages worth of docs tucked away in a google doc that isn't up to date. I need to talk to Kris and find out exactly where it's at.
Reply all
Reply to author
Forward
0 new messages