O'Reilly logo

JavaScript JSON Cookbook by Ray Rischpater

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using REST to search MongoDB

By now, that you might be wondering where JSON comes into play when using MongoDB. When you access a MongoDB database instance using a RESTful interface such as mongo-rest, the documents are transferred to the client using JSON. Let's see how to get a list of documents from MongoDB.

How to do it...

Using REST with Node.js and MongoDB takes several steps.

  1. Be sure you've set up the REST server as we discussed in the introduction. You'll need to have created the files rest-server.js, routes/documents.js, and mongo-rest-example.html with the UI for our RESTful application, and run both the REST server and the document server with Node.js.
  2. Second, be sure that you're running MongoDB.
  3. Next, to process the REST GET request, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required