HTML and CSS Reference
In-Depth Information
Connecting to a Database
To track how many times the users click their blob and prevent them from clicking too frequently, you need a
storage mechanism. As mentioned earlier, the mechanism used is the popular NoSQL database MongoDB.
Installing MongoDB on Windows
To install MongoDB you can download a recent version from its website at www.mongodb.org/downloads .
This is the recommended installation method for Windows. You need to download the correct version for
the version of Windows you run, either 32 bit or 64 bit. After you have the file downloaded, unzip the folder
to some location. ( C:\Program Files\ is a good spot.) You probably want to rename the resulting folder
from mongo-xxxxxxx (where xxxxxxx is the version number you downloaded) to just mongo .
When you have the folder downloaded, you need to create a data directory. Mongo uses the directory
C:\data\db by default, but it won't create those directories for you. Create the directories in Explorer or by
launching the CMD terminal window and running the following:
C:\> mkdir \data
C:\> mkdir \data\db
After you create that folder, you can CD to the mongo\bin directory:
C:\> cd \Program Files\mongo\bin
From there you can run the mongod command to start the database server:
C:\Program Files\mongo> mongod
This launches the server. (You need to keep the window open.) For up-to-date installation instructions,
see the Windows Quickstart tutorial on the Mongodb website at www.mongodb.org/display/DOCS/Quick-
start+Windows .
You'll probably get tired of running Mongo from the command line, so to set it up to run as a service, you
can see further instructions at www.mongodb.org/display/DOCS/Windows+Service .
Installing MongoDB on OS X
On OS X, if you followed the instructions in Chapter 8, “Running JavaScript on the Command Line,” you can
use Homebrew to install MongoDB:
$ brew install mongo
This should install MongoDB and start the server for you. If you don't have Homebrew installed, you need
to download the software and follow the Quickstart instructions on the website.
Installing MongoDB on Linux
On Linux, you can use your package manager to install a recent version. On Ubuntu or Debian this means run-
ning the following:
$ apt-get install mongodb
This should install MongoDB and start the server for you as well.
Search WWH ::




Custom Search