MongoCollectionFindOne
MongoCollectionFindOne[MongoCollection[…]]
returns the first document in MongoCollection.
MongoCollectionFindOne[MongoCollection[…],query]
returns the first document matching the query query.
MongoCollectionFindOne[MongoCollection[…],query,projection]
the fields included in the document are controlled by projection.
Details and Options
- To use MongoCollectionFindOne, you first need to load MongoLink using Needs["MongoLink`"].
- Both query and projection are Associations.
- See "Query and Projection Operators" in the MongoDB documentation for available query and projection operators.
- MongoCollectionFindOne corresponds to db.collection.findOne() in the MongoDB documentation.
- See also the "Query Documents" and "Project Fields to Return from Query" tutorials in the MongoDB documentation.
Examples
Basic Examples (1)
Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:
Find the first document in the collection:
Find the first document in the collection that matches the query <|"age"5|>:
Find the first document in the collection that matches the query <|"age"4|>, without returning the "date" field:
Text
Wolfram Research (2018), MongoCollectionFindOne, Wolfram Language function, https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html.
CMS
Wolfram Language. 2018. "MongoCollectionFindOne." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html.
APA
Wolfram Language. (2018). MongoCollectionFindOne. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html