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.
Some requirements:
- Wide browser compatibility. Anything that can run jQuery is fine. I’d actually prefer that it be a jQuery plugin.
- Can sort on more than one column. For instance, order by state alphabetically and list all cities alphabetically within each state.
- Can filter results. For instance, the equivalent of “where state = ‘CA’ or ‘NY’ or ‘TX'”.
- Must work completely client side so the user only needs to download a large set of data once and can cut the data however they want without constantly fetching data from the server and would in fact be able to do all queries offline after the initial pull.
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.
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.
Edit: I think I should include a use case to help clarify what I’m looking for.
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.
- Ten largest cities in California
- All cities that start with “S” with populations of 1,000,000 or more.
- Largest three cities in California, New York, Florida, Texas, and Illinois and order them alphabetically by state then by population. i.e. California, Los Angeles, 3,792,621; California, San Diego, 1,307,402; California, San Jose, 945,942…etc.
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.
Take a look at http://linqjs.codeplex.com/
It easily meets all your requirements.