
This puts you into the Node.js interactive environment where you can execute JavaScript expressions.Įnter the following expression at the prompt:Ĭonsole.log is the Node.js equivalent of NSLog. Once the installer has completed, you can test out your Node.js installation right away. You’ll need this later to launch the MongoDB service.ĭownload and run the Node.js installer from. Make a note of the directory where MongoDB is installed as shown in the “Summary” output. Now, install MongoDB via Homebrew with the following command: This simply updates Homebrew so you have the most up-to-date package list. Once Homebrew is installed, enter the following command in Terminal: You use it here to load the Homebrew installation script - later on in this tutorial you’ll use it to interact with the Node server. Note: cURL is a handy tool to send and receive files and data using URL requests. Otherwise, install Homebrew by opening Terminal and executing the following command: ruby -e "$(curl -fsSL )" If you already have Homebrew installed, feel free to skip to the next step. It’s built on top of Ruby and Git and is highly flexible and customizable. Just as CocoaPods manages packages for Cocoa and Gem manages packages for Ruby, Homebrew manages Unix tools on Mac OS X. This tutorial assumes you have OS X Mountain Lion or Mavericks, and Xcode with its command line tools already installed. Node and MongoDB are inherently scalable and synchronize easily across multiple machines in a distributed model this combination is a good choice for applications that don’t have an evenly distributed load.

Since BSON is compatible with JSON, building a REST API is simple - the server code can pass requests to the database driver without a lot of intermediate processing. This lets you work with heterogeneous data and makes it easy to handle a wide variety of data formats. MongoDB is a low-overhead database where all entities are free-form BSON - “binary JSON” - documents. Asynchronous event-driven programming model.Īn asynchronous programming model of events and callbacks is well suited for a server which has to wait for a lot of things, such as incoming requests and inter-process communications with other services (like MongoDB).

