📜 ⬆️ ⬇️

Execution of SQL-like queries on the data - both in the browser and on the server

Marak Squires released JSLINQ , a LINQ implementation for JavaScript that works both on the browser side and on the server side (for example, node.js ). Designs such as JOIN, UNION, RANGE, DISTINCT, COUNT etc. are supported.

See:

Jslinq


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

* This source code was highlighted with Source Code Highlighter .

By the way, XaocCPS once talked about the jLinq project, and Karl Gertin mentioned the JSINQ project, which can also be viewed.

jLinq


var results = jLinq.from(data.users)
.startsWith( "first" , "a" )
.orEndsWith( "y" )
.orderBy( "admin" , "age" )
.select();


* This source code was highlighted with Source Code Highlighter .

Jsinq


var query = new jsinq.Query( '\
from order in $1 \
group order by order.customerId into g \
select {customerId: g.getKey(), items: g.sum(function(g) { return g.items; })} \
into h \
join customer in $0 on h.customerId equals customer.id \
where h.items > 10 \
orderby h.items descending \
select {lastname: customer.lastname, items: h.items} \
'
);

query.setValue(0, customers);
query.setValue(1, orders);
var result = query.execute();


* This source code was highlighted with Source Code Highlighter .

')

Source: https://habr.com/ru/post/92867/


All Articles