Number of documents in a collection in MongoDB using RMongo

251 Views Asked by At

How can I find the number of documents in a collection using the RMongo package?

1

There are 1 best solutions below

0
cderv On

You could use the rmongodb package which has more recent updates.

Connect to your base (here localhost) and use mongo.count to count documents in a specific collection.

library(rmongodb)
mongo <- mongo.create() 
mongo.count(mongo = mongo, ns = coll_name) 

With the argument query you also could count document resulting of a specific query if you want.