MongoDB is a scalable, high-performance, open source NoSQL database.
MongoDB’s most common features
- Document-Oriented Storage - JSON-style documents with dynamic schemas offer simplicity and power.
- Full Index Support - Index on any attribute, just like you’re used to.
- Querying - Rich, document-based queries.
In addition, MongoDB has many scalability features such as:
Installing MongoDB on a Cloud9 workspace
To install MongoDB in your workspace, you can open a terminal and run the following command:
sudo apt-get install -y mongodb-org
Running MongoDB on a Cloud9 workspace
MongoDB is preinstalled in your workspace. To run MongoDB, run the following below (passing the correct parameters to it). Mongodb data will be stored in the folder
$ mkdir data $ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod $ chmod a+x mongod
You can start mongodb by running the
mongod script on your project root:
MongoDB parameters used:
--dbpath=data - Because it defaults to
/var/db (which isn’t accessible)
--nojournal - Because mongodb usually pre-allocates 2 GB journal file (which exceeds Cloud9 disk space quota)
--bind_ip=$IP - Because you can’t bind to 0.0.0.0
--rest - Runs on default port 28017
You should use the host
$IP instead of
localhost as your driver connection URL. For example, in Node, it is:
MongoDB has drivers for all supported runtimes. Following are the most commonly used drivers:
To access a shell prompt for the above MongoDB run the following.
Check out docs.mongodb.org for details on how to use the shell