Querying data with JavaScript - Stack Overflow

I am currently looking for an intelligent best practice solution for the following problem. Within a we

I am currently looking for an intelligent best practice solution for the following problem. Within a web page, I want to make use of data that is currently organised in some MySQL tables.

Problem: I cannot access the database from the webserver, so I am not able to query the data using SQL. Therefore, I thought to transform the data into something JavaScript can handle (e.g. JSON) and perform all the operations on the data on client-side.

Doing SQL-like queries on an object will probably be kind of hard, even if those I need will probably be easy (simple SELECTs). Is there a elegant way to do that? Some nice little javascript library?

Thanks in advance for your ideas.

I am currently looking for an intelligent best practice solution for the following problem. Within a web page, I want to make use of data that is currently organised in some MySQL tables.

Problem: I cannot access the database from the webserver, so I am not able to query the data using SQL. Therefore, I thought to transform the data into something JavaScript can handle (e.g. JSON) and perform all the operations on the data on client-side.

Doing SQL-like queries on an object will probably be kind of hard, even if those I need will probably be easy (simple SELECTs). Is there a elegant way to do that? Some nice little javascript library?

Thanks in advance for your ideas.

Share Improve this question asked Jun 21, 2010 at 8:48 auralbeeauralbee 8,8514 gold badges32 silver badges36 bronze badges 2
  • are you using any databases right now? if yes, what kind of access do you have for it? – Anurag Commented Jun 21, 2010 at 9:04
  • if you cannot access the db then surely you will not able able to access the db with js either? – matpol Commented Jun 21, 2010 at 9:09
Add a ment  | 

2 Answers 2

Reset to default 3

Best practice would (of course) be to put some kind of link (even if not a direct one) between the database and the web server.

For SQL in the browser, though, there's the TrimQuery library, basically a mini-SQL engine written in JavaScript for use on the browser. You would output the "tables" as arays of objects using JSON (as you indicated), and then query it via TrimQuery's SQL support.

But if you can't access the database from the web server, I assume you'll be making a mostly-static copy of the data as an admin procedure and placing it on the webserver. That being the case, you may well be better off determining your usage patterns in your web app and then formatting the data into useful objects as part of the DB->web server copy operation. But if you really need ad-hoc queries into the data, TrimQuery may be a route you could use.

You can try JSINQ:

http://jsinq.codeplex./

which is a Javsascript LINQ implementation. It allows to "query" json object with linq expressions (then in a sql-like way).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641331a4637712.html

相关推荐

  • Querying data with JavaScript - Stack Overflow

    I am currently looking for an intelligent best practice solution for the following problem. Within a we

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信