I use rmongodb to read and display some information from local host mongo db. Data is inserted directly using mongo shell. There is a text file MongoDataManipulation.txt that shows the data manipulation commands and the test data
Install necessary packages and load them
#install.packages("rmongodb")
library(rmongodb)
Connect to local host and check the connection status
m<-mongo.create()
mongo.is.connected(m)
## [1] TRUE
list the collection of databases
mongo.get.databases(m)
## [1] "test" "database" "db"
Get a list of collection from the test db, where the data is stored.
mongo.get.database.collections(m, db = "test")
## [1] "test.inventory"
Get the count of documents in my collection
ns <- "test.inventory"
mongo.count(m, ns = ns)
## [1] 2
Get all the documents from the collections.
Display the count of documents fetched