mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "age", 22L)
query <- mongo.bson.from.buffer(buf)
# Find the first 100 records
# in collection people of database test where age == 22
cursor <- mongo.find(mongo, "test.people", query, limit=100L)
res <- mongo.cursor.to.data.frame(cursor)
}
Run the code above in your browser using DataLab