Learn R Programming

rmongodb (version 1.8.0)

mongo.distinct: Get a vector of distinct values for keys in a collection

Description

Get a vector of distinct values for keys in a collection.

Usage

mongo.distinct(mongo, ns, key, query = mongo.bson.empty())

Arguments

mongo
(mongo) A mongo connection object.
ns
(string) The namespace of the collection in which to find distinct keys.
key
(string) The name of the key field for which to get distinct values.
query
mongo.bson An optional query to restrict the returned values.

Value

vector of distinct values or NULL if the command failed.(vector) The result set of distinct keys.

Details

See http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct.

See Also

mongo.command, mongo.simple.command, mongo.find, mongo.

Examples

Run this code
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    keys <- mongo.distinct(mongo, "test.people", "name")
    print(keys)
}

Run the code above in your browser using DataLab