tc / RMongo

R client to interface with MongoDB
102 stars 34 forks source link

run dbGetQueryForKeys without limiting the number of items returned #9

Closed defoo closed 10 years ago

defoo commented 13 years ago

Running "dbGetQueryForKeys" requires the user to enter a "limit" to control the items return. It would be nice if the limit parameter can be set to something like "-1" to return everything the matches the query.

Currently, this is the work around I use to get all matched items:

occurances <- dbGetQueryForKeys(mongo, "mycollection", query, keys, 0, batch_size ) all_occ <- NULL skip <- 0 while ( nrow(occurances) > 0 ) { occurances <- dbGetQueryForKeys(mongo, "mycollection", query, keys, as.numeric(skip), batch_size )
all_occ <- rbind( all_occ , occurances) skip <- skip + nrow(occurances) }

tc commented 10 years ago

Unfortunately not forcing a limit can crash a computer if there are millions of rows.