简体   繁体   English

新的javascript / jquery库可以对JSON数据进行类似SQL的查询吗?

[英]New javascript/jquery library that allows for SQL-like queries on JSON data?

This question was asked about a year ago to date . 迄今为止,这个问题是一年前提出的。 As I've done google searches for answers to this question, all the libraries I've found seem to not have had any activity for about a year. 当我完成Google搜索此问题的答案时,我发现的所有图书馆似乎都没有活动大约一年了。 I'm just wondering if anyone out there is aware of any libraries that are currently maintained, or what other alternatives people do? 我只是想知道是否有人知道当前正在维护的任何库,或者人们还有其他替代方法吗?

I'm looking to do some client-side data filtering, and I'm open to other suggestions beyond writing my own functions. 我正在寻求一些客户端数据过滤功能,除了编写自己的函数外,我还接受其他建议。

You can try Alasql JavaScript library. 您可以尝试Alasql JavaScript库。 It supports queries on JSON arrays with full SQL functionality. 它支持具有完整SQL功能的JSON数组查询。

Here is and example: 这是示例:

 <script src="alasql.min.js"></script>
 <script>
     var cars = [{model:'Mazda', price:20000}, {model:'Toyota', price:25000}, 
        {model:'Ford', price:22000}];

     var res = alasql("SELECT * FROM ? WHERE price > 21000",[cars]);

     console.log(res);
 </script>

Try this example in jsFiddle . 在jsFiddle中尝试此示例。

您可能想签出taffydbWeb sql数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM