How to find a document by using its name using MongoC

26 views
Skip to first unread message

JAED

unread,
Mar 14, 2018, 5:15:12 PM3/14/18
to mongodb-user
Hello,

I am currently using MongoC library and I need to find a document that was created previously. I know the name of this document and I would like to retrieve the document by using its name.
Is this possible with functions like "mongoc_collection_find" ? How do I need to set the arguments?
Is there another function capable of finding a document by passing database name, collection name and document name as arguments?

Thanks.

Regards.

Wan Bachtiar

unread,
Mar 18, 2018, 10:06:37 PM3/18/18
to mongodb-user

Is this possible with functions like “mongoc_collection_find” ? How do I need to set the arguments?

Hi Jaed,

To get started, I would recommend to follow the MongoDB C Driver Tutorial. Especially on the section Finding a Document.

The tutorial contains an example as below:

//  Look for all documents matching {"hello" : "world"}.
query = bson_new ();
BSON_APPEND_UTF8 (query, "hello", "world");
cursor = mongoc_collection_find_with_opts (collection, query, NULL, NULL);

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages