如何在客户端浏览器中执行类似SQL的查询? [英] How to do SQL-like queries in client side browser?

查看:261
本文介绍了如何在客户端浏览器中执行类似SQL的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方法来执行复杂的查询,例如SQL可以执行但完全在客户端执行.我知道我可以从服务器上执行SQL查询来获得所需的准确结果,甚至可以AJAX使其看起来很平滑.但是出于可伸缩性,性能和带宽的原因,我宁愿在客户端进行此操作.

I've been looking for a way to do complex queries like SQL can perform but totally client side. I know that I can get the exact results that I want from doing SQL queries off of the server and I could even AJAX it so that it looks smooth. However for scaleability, performance, and bandwidth reasons I'd prefer to do this all client side.

一些要求:

  • 广泛的浏览器兼容性.任何可以运行jQuery的工具都可以.实际上,我更希望它是一个jQuery插件.
  • 可以对多个列进行排序.例如,按字母顺序按州排序,并按字母顺序列出每个州内的所有城市.
  • 可以过滤结果.例如,相当于"where state ='CA'或'NY'或'TX'".
  • 必须完全在客户端上工作,因此用户只需要下载一次大数据集即可剪切数据,但是他们希望在不不断从服务器获取数据的情况下进行操作,实际上,在初始操作之后,用户就可以脱机执行所有查询拉.

我到处查看了stackoverflow并发现了jslinq,但它的最新更新时间为2009年,没有文档.我也无法确定它是否可以执行更复杂的查询,例如在两个不同的列上进行排序或执行与"或或"过滤.

I've looked around on stackoverflow and found jslinq but it was last updated in 2009 and has no documentation. I also can't tell if it can do more complex queries like ordering on two different columns or doing "and" or "or" filtering.

我认为这样的事情已经做完了.我知道HTML5是沿着这条道路开始的,但后来遇到了障碍.我只需要基本查询,没有联接或任何东西.有谁知道可以做到这一点的东西?谢谢.

I would think that something like this would have been done already. I know HTML5 got started down this path but then hit a roadblock. I just need basic queries, no joins or anything. Does anyone know of something that can do this? Thanks.

我想我应该包括一个用例,以帮助阐明我在寻找什么.

I think I should include a use case to help clarify what I'm looking for.

例如,我列出了美国5000个最大的城市.每个记录包括城市名称,州和人口.我希望能够一次下载整个数据集并用它填充一个JS数组,然后仅在客户端上就可以运行如下查询,并根据结果记录创建表.

For example, I have a list of the 5000 largest cities in the US. Each record include Cityname, State, and Population. I would like to be able to download the entire dataset once and populate a JS array with it then, on the client side only, be able to run queries like the following and create a table from the resulting records.

  • 加利福尼亚州十个最大的城市
  • 所有以"S"开头且人口超过1,000,000的城市.
  • 加利福尼亚,纽约,佛罗里达,得克萨斯州和伊利诺伊州的三个最大城市,并按州和人口先后按字母顺序排列.即加利福尼亚州洛杉矶,3,792,621;加利福尼亚,圣地亚哥,1,307,402;加利福尼亚州,圣何塞,945942 ...等.

所有这些查询都可以通过SQL来完成,但我不想一直往返于服务器,并且我也希望允许脱机使用.

All of these queries would be trivial to do via SQL but I don't want to keep going back and forth to the server and I also want to allow offline use.

推荐答案

看看 http://linqjs.codeplex .com/

它很容易满足您的所有要求.

It easily meets all your requirements.

这篇关于如何在客户端浏览器中执行类似SQL的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆