Reading data from NoSQL databases – MongoDB
Unlike relational databases for which a somewhat standard approach works across all relational databases, the fluid state of NoSQL databases means that no such standard approach has yet evolved. We illustrate this with MongoDB using the rmongodb
package.
Getting ready
Prepare the environment by following these steps:
- Download and install MongoDB.
- Start
mongod
as a background process and then startmongo
. - Create a new database
customer
and a collection calledorders
:> use customer > db.orders.save({customername:"John", orderdate:ISODate("2014-11-01"),orderamount:1000}) > db.orders.find() > db.save
How to do it...
To read data from MongoDB, follow these steps:
- Install the
rmongodb
package and create a connection: ...
Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.