mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Jeff")
criteria <- mongo.bson.from.buffer(buf)
# remove all records where name is "Jeff"
# from collection people in database test
mongo.remove(mongo, "test.people", criteria)
# remove all records from collection cars in database test
mongo.remove(mongo, "test.cars")
# shorthand: remove all records where name is "Fred"
mongo.remove(mongo, "test.people", list(name="Fred"))
}
Run the code above in your browser using DataLab