Description Usage Arguments Details See Also Examples
View source: R/mongo_records.R
Remove all records from a collection that match a given criteria.
1 | mongo.remove(mongo, ns, criteria = mongo.bson.empty())
|
mongo |
(mongo) a mongo connection object. |
ns |
(string) namespace of the collection from which to remove records. |
criteria |
(mongo.bson) The criteria with which to match records that are to be removed. The default of mongo.bson.empty() will cause all records in the given collection to be removed. Alternately, Alternately, |
See http://www.mongodb.org/display/DOCS/Removing.
mongo,
mongo.bson,
mongo.insert
,
mongo.update
,
mongo.find
,
mongo.find.one
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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"))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.