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.
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.
更多信息和选项
- 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.
范例
基本范例 (1)
Needs["MongoLink`"]client = OpenMongoConnection[]Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:
coll = client["WolframTestDB"]["WolframTestCollection"]Find the first document in the collection:
MongoCollectionFindOne[coll]Find the first document in the collection that matches the query <|"age"5|>:
MongoCollectionFindOne[coll, <|"age" -> 5|>]Find the first document in the collection that matches the query <|"age"4|>, without returning the "date" field:
MongoCollectionFindOne[coll, <|"age" -> 4|>, <|"date" -> False|>]技术笔记
相关指南
文本
Wolfram Research (2018),MongoCollectionFindOne,Wolfram 语言函数,https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html.
CMS
Wolfram 语言. 2018. "MongoCollectionFindOne." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html.
APA
Wolfram 语言. (2018). MongoCollectionFindOne. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html 年
BibTeX
@misc{reference.wolfram_2026_mongocollectionfindone, author="Wolfram Research", title="{MongoCollectionFindOne}", year="2018", howpublished="\url{https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html}", note=[Accessed: 15-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_mongocollectionfindone, organization={Wolfram Research}, title={MongoCollectionFindOne}, year={2018}, url={https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionFindOne.html}, note=[Accessed: 15-August-2026]}