Access MongoDB directly through JavaScript

is it possible to access and receive data from MongoDB directly through a JavaScript form browser without processing the backend?

+44
json javascript database ajax mongodb
Jan 25
source share
3 answers

MongoDB does not initially have a fully usable REST interface. You will need Sleepy Mongoose based on Python or MongoDB Rest based on Node.js

Please see http://www.mongodb.org/display/DOCS/Http+Interface for more information.

Mongo's built-in REST interface is very simple & read-only

+17
Sep 14 2018-11-11T00:
source share

Not in a standard security context.

If you have elevated security rights (for example, inside a custom browser extension), this may be possible.

+2
Jan 25 '10 at 3:29
source share

If you want to host your database on MongoLabs, they also provide a REST API. Beware, it is not secure, as the API key is passed with every request, but you can use it to retrieve public data through Javascript:

https://support.mongolab.com/entries/20433053-Is-there-a-REST-API-for-MongoDB-

Once you have mongolab db configured, you can access it through a REST request, for example

$.getJSON( "https://api.mongolab.com/api/1/databases/your-db/collections/your-collection/? apiKey=your-key", function( json ) { //console.log( "JSON Data: " + json ); } ); 
+1
Oct. 25 '13 at 16:14
source share



All Articles