How to connect to mongodb from client-side javascript?

Question:

good day dear JavaScript gurus. Is it possible to directly connect to mongodb from client-side javascript? I have a large mongodb database and wanted to directly read data from it for display in a web application without unnecessary intermediaries on the backend. Among mongodb-drivers I found only those written for node.js, but not for client JavaScript. are there options to connect directly from the browser? I found close questions on the forums, but there was only chatter about the topic that such options are not needed at all and no connection examples

Answer:

The mongod process has a simple REST api that is disabled by default. It has no support for insert, update and delete operations and is intended for administrative tasks. To enable it, you need to run Mongu with the –rest key. See https://docs.mongodb.com/ecosystem/tools/http-interfaces/#simple-rest-api

Scroll to Top