Learn R Programming

One4All (version 0.5)

query_document_by_object_id: Query a MongoDB document by an ObjectID

Description

This function queries a mongodb database using its API to retrieve a document by its ObjectID. Use the MongoDB Atlas Data API to create an API key.

Usage

query_document_by_object_id(apiKey, collection, database, dataSource, objectId)

Value

The queried document.

Arguments

apiKey

The API key for accessing the MongoDB API.

collection

The name of the collection in the MongoDB database.

database

The name of the MongoDB database.

dataSource

The data source in MongoDB.

objectId

The object ID of the document to query.

Examples

Run this code
if (FALSE) {
apiKey <- 'your_mongodb_api_key'
collection <- 'your_mongodb_collection'
database <- 'your_database'
dataSource <- 'your_dataSource'
objectId <- 'example_object_id'
query_document_by_object_id(apiKey, collection, database, dataSource, objectId)
}

Run the code above in your browser using DataLab