Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  145] [ 7]  / answers: 1 / hits: 20472  / 12 Years ago, sun, october 7, 2012, 12:00:00

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();
}
});


Is there a way to interface with MongoDB this way?


More From » jquery

 Answers
69

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



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



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


[#82713] Friday, October 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darennevina

Total Points: 422
Total Questions: 128
Total Answers: 105

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;