mongo.remove: Remove records from a collection

Description Usage Arguments Details See Also Examples

View source: R/mongo_records.R

Description

Remove all records from a collection that match a given criteria.

Usage

1

Arguments

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, criteria may be a list which will be converted to a mongo.bson object by mongo.bson.from.list().

Alternately, criteria may be a valid JSON character string which will be converted to a mongo.bson object by mongo.bson.from.JSON().

Details

See http://www.mongodb.org/display/DOCS/Removing.

See Also

mongo,
mongo.bson,
mongo.insert,
mongo.update,
mongo.find,
mongo.find.one.

Examples

 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"))
}

jonkatz2/rmongodb documentation built on May 19, 2019, 7:30 p.m.