Learn R Programming

RMongo (version 0.0.25)

dbGetDistinct-methods: Performing a distinct MongoDB query

Description

Send a json query to mongodb. The output is a data.frame object and will work properly only if the mongoDB collection contains primitive data types. It may not work properly if there are any embedded documents or arrays.

Usage

dbGetDistinct(rmongo.object, collection, key, query)

Arguments

rmongo.object
The RMongo object.
collection
The name of the collection the query is being performed upon.
key
A JSON string query. See http://www.mongodb.org/display/DOCS/Advanced+Queries for more information on the MongoDB query language.
query
A JSON string query. See http://www.mongodb.org/display/DOCS/Advanced+Queries for more information on the MongoDB query language.

See Also

mongoDbConnect

Examples

Run this code
  mongo <- mongoDbConnect("test")
  output <- dbInsertDocument(mongo, "test_data", '{"foo": "bar"}')
  output <- dbInsertDocument(mongo, "test_data", '{"foo": "bar"}')
  output <- dbGetDistinct(mongo, 'test_data', '{"foo": "bar"}')
  print(output)

Run the code above in your browser using DataLab