Questions tagged [mongo-c-driver]

Officially supported C Driver for MongoDB

MongoDB C Driver is an officially supported driver for MongoDB. It is written in pure C.

More information:

126 questions
0
votes
0 answers

mongoc driver: write query in mongoc driver in C

I have a collection named example_Collection with data of format: { { "_id": ObjectId("100"), "source_timestamp":{ "sec" : 90000 } } { "_id": ObjectId("200"), "source_timestamp":{ "sec" : 95000 } { "_id": ObjectId("300"), …
Kavita Jain
  • 90
  • 1
  • 9
0
votes
1 answer

How to get errors when calling mongoc_collection_find function?

Looking at the functions used in the Mongo C driver to do operations on collections, I see that many of them use a bson_error_t* return parameter to get possible errors (and they return false in that case). For instance…
fgalan
  • 11,732
  • 9
  • 46
  • 89
0
votes
2 answers

How to insert document with empty key using Mongo C driver?

I have this program in C (a slight variation of the hello world example at Mongo C driver documentation: #include #include #include // file insert.c // compiled with: gcc -o insert insert.c $(pkg-config…
fgalan
  • 11,732
  • 9
  • 46
  • 89
0
votes
1 answer

Undefined reference to symbol error when linking Mongo C driver static library

I'm trying to build a program using the Mongo C driver. My CMake configuration includes this: include_directories("/usr/local/include/libmongoc-1.0") include_directories("/usr/local/include/libbson-1.0") ... SET (STATIC_LIBS ... …
fgalan
  • 11,732
  • 9
  • 46
  • 89
0
votes
1 answer

Is it possible to not stub mongo-c-driver whiling using GTests?

I wrote some basic funtions that uses mongodb-c-driver. and I tried to write some tests with GTest. in each test case I init and destroy mongoc with ( mongoc_init() and mongoc_cleanup()). When I run one test case, everything goes fine but when I run…
kml2019
  • 63
  • 6
0
votes
0 answers

Make Error : Unknown CMake command "set_dist_list" when building mongo c driver 1.17.3

I am trying to build a mongocxx c driver with the latest release. I am doing this with minGW makefiles and am using cmake-gui. My configuration for cmake is: Source input: C:/****/mongo-c-driver-1.17.3/build Build…
0
votes
1 answer

How to create a TTL index with Mongoc (mongo c lib)

I'm trying to add a TTL index in my mongodb with mongoc lib http://mongoc.org/. What I'm doing is : keys = BCON_NEW("createdAt", BCON_INT32(1), "expireAfterSeconds", BCON_INT32(30)); index_name =…
kml2019
  • 63
  • 6
0
votes
1 answer

mongocxx count documents in collection

Counting the number of documents in a collection is easy and fast (apparently constant time) in the shell. > db.my_collection.count() 12345678 > In C++ I try this: mongocxx::client client; mongocxx::database db = MongoInit(client,…
jma
  • 3,580
  • 6
  • 40
  • 60
0
votes
1 answer

How do I create an array for an updateOne() call in mongoc (C libarary for Mongodb)?

I am completely mystified (and supremely frustrated). How do I create this call using the mongoc library? I have the following doc structure in the collection {_id: myOID, subsriptions: { newProducts: true, newBlogPosts: true, …
0
votes
1 answer

mongodb c++ QString to kvp() value

I'm struggling to get a valid conversion of my qstring to whatever kvp needs inside mongo... I tried std::string_view k(documentKey.toStdString().c_str());//, documentKey.size()); // tried adding size as wll std::string_view…
Dariusz
  • 960
  • 13
  • 36
0
votes
1 answer

MongoDB project nested element in _id field

I'm stuck in something very stupid but I can't get out from my own. MongoDB v4.2 and I have a collection with documents like this: {"_id":{"A":"***","B":0}}, "some other fields"... I'm working on top of mongo-c driver and I want to query only the…
Héctor
  • 399
  • 3
  • 16
0
votes
1 answer

How to do transactions using MongoDB C driver with FoundationDB Document Layer?

The mongoc documentation for transaction uses session. So I tried to insert documents within a transaction associated with a session. But I got the error [ 3666]: ERROR: mongoc: Failed to start session: Server does not support sessions How…
John Doe
  • 2,225
  • 6
  • 16
  • 44
0
votes
1 answer

Problem executing code (C/Mongo C driver) on different installation than where first compiled

I have a program compiled and running on Ubuntu server 16.04, in C using Mongo C driver. This works without a problem. If I move this executable to a new installation, I get an error when executing; testuser@usrv1604:~/bin$…
RR1
  • 333
  • 1
  • 6
  • 13
0
votes
1 answer

How to correct symbol lookup error in MongoDb C client

When I run the hello_mongoc test app (renamed to mongotest), the output looks like this: { "ok" : 1 } ./mongotest: symbol lookup error: /usr/local/lib/libmongoc-1.0.so.0: undefined symbol: bson_validate_with_error The app is build with: cc -o…
willemx
  • 530
  • 7
  • 19
0
votes
0 answers

How can I retrieve data from mongoc_collection_find_with_opts

Following are snippets of my code in C, redacted for ease of reading: bCursor = mongoc_collection_find_with_opts(...); mongoc_cursor_next(bCursor, &bDoc); where I get the document in bDoc as json: { "_id" : { "$numberInt" : "4184300" }, …
Lee Chua
  • 11
  • 3
1 2 3
8 9