使用MongoDB的客户端jQuery应用程序 [英] Client-side jQuery application with MongoDB

查看:318
本文介绍了使用MongoDB的客户端jQuery应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个非常简单的示例应用程序来熟悉使用MongoDB。从本质上讲,我想要一个查询本地MongoDB服务器的网页,使用jQuery动态添加和删除内容。我没有任何问题将页面布局和jQuery放在一起,但是我越来越被MongoDB的部分混淆了。我了解MongoDB是一个服务器并从客户端远程运行,但对于我的示例,我只是希望能够从客户端浏览器中的JavaScript快速轻松地进行查询:

I'm trying to write a very simple example application to familiarize myself with using MongoDB. Essentially, I'd like to have a single web page which queries a local MongoDB server, adding and removing content dynamically using jQuery. I have no problem at all throwing together the page layout and the jQuery, but I'm getting more and more confused by the MongoDB part of the equation. I understand that MongoDB is a server and runs remotely from the client, but for my example, I simply want to be able to query quickly and easily from client-side in-browser JavaScript:

$("#toggle").click(function() {
    if ($(this).is(":checked") {
        // add items from mongodb
        addItems(mongodb.test.find({ age: { $gt: 5 }}));
    } else {
        $("#results").hide();
    }
});



<有没有办法以这种方式与MongoDB连接?

Is there a way to interface with MongoDB this way?

推荐答案

您需要一个驱动程序才能连接到MongoDB服务器。司机列表在这里:
http://www.mongodb.org/display/DOCS/Drivers

You need a driver to connect to a MongoDB server. The list of drivers is here: http://www.mongodb.org/display/DOCS/Drivers

有一个JS驱动程序,但仅适用于服务器端JS - 特别是node.js

There is a JS driver, but only for server side JS - specifically node.js

Bottomline,你不能直接从浏览器连接。你需要一个服务器端组件。

Bottomline, you can't connect directly from a browser. You need a server side component.

这篇关于使用MongoDB的客户端jQuery应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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