mongo-c-driver

Using MongoDb c driver to extract array from bson

大城市里の小女人 提交于 2021-02-08 10:35:13
问题 I have documents in a mongo collection which look like: { "f" : [ 283, 180, 284 ], "l":["1","29"] } I am using the mongoDB c driver to fetch these documents and perform some operations on these> I would like to restore element "f" back as an array of integers and the element "l" back as an two multidimensional char array. while (mongoc_cursor_next (cursor, &doc)) { bson_iter_t it; bson_iter_init(&it, doc); while (bson_iter_next(&it)) { const char * key=bson_iter_key(&it); bson_type_t type

Problem installing Mongo C Driver on ubuntu 16.04

和自甴很熟 提交于 2020-12-13 04:16:49
问题 I have installed the Mongo C Driver on ubuntu 16.04 using the command: sudo apt-get install libmongoc-1.0-0 When I try to compile using cmake, I get the following errors: rolf@ubuntu2:~/src/test$ cmake . -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile

Problem installing Mongo C Driver on ubuntu 16.04

拈花ヽ惹草 提交于 2020-12-13 04:16:26
问题 I have installed the Mongo C Driver on ubuntu 16.04 using the command: sudo apt-get install libmongoc-1.0-0 When I try to compile using cmake, I get the following errors: rolf@ubuntu2:~/src/test$ cmake . -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile

mongo c driver: how to query documents with “_id” in a list?

本小妞迷上赌 提交于 2019-12-24 22:17:01
问题 I have a db with huge amount of documents, and I only want to query documents with "_id" from a list. I searched online for a few hours, and did not find anything really working, so I post my question here. Thank you very much for any help! in MongoDB command line environment, it is very easy to achieve what I want. The query command, for example, is as follows: db.collection.find({"_id":{$in:[ObjectId("595320c208b0c52a8b37c151"), ObjectId("595320c208b0c52a8b37c152"), ObjectId(

cannot compile mongo-c-driver example

ⅰ亾dé卋堺 提交于 2019-12-22 05:23:29
问题 I try to write simple mongo c client. Source file (a.c): #include <stdio.h> #define MONGO_HAVE_STDINT #include <mongo.h> void mongo_init_c(mongo *con) { mongo_init(con); } int main() { return 0; } And i try to compile it with: gcc -I/usr/local/include -L/usr/local/lib -lmongoc a.c But get an error: a.c:(.text+0xd): undefined reference to `mongo_init' Files /usr/local/include/mongo.h and /usr/local/lib/libmongoc.so exists How can I correctly compile a.c? p.s. mongo-2.0.4, gcc-4.6, mongo-c

为Windows版PostgreSQL编译mongo_fdw准备篇

落爺英雄遲暮 提交于 2019-12-17 17:21:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 有朋友问如何编译 mondb_fdw 的Windows版,本文是准备依赖包的过程。 1、下载Windows版CMake 网址: https://cmake.org/download/ 下载zip包即可,我们可以手动在命令行设置path,没必要用安装程序。 当前版本 3.15.3,解压到 C:\cmake-3.15.3-win64-x64。 2、下载MongoDB C Driver 网址: http://mongoc.org/ 当前版本 1.15.1,解压至 C:\mongo-c-driver-1.15.1 (Windows下解压 tar 文件可使用 7-zip ) 3、微调代码 src/libbson/src/bson/bson-macros.h 这里的内存对齐在Windows下有点问题,粗暴地注释掉 #ifdef BSON_EXTRA_ALIGN ... 改为 #define BSON_ALIGNED_BEGIN(_N) #define BSON_ALIGNED_END(_N) 4、生成微软工程文件 参考: http://mongoc.org/libmongoc/current/installing.html set path=%path%;C:\cmake-3.15.3-win64-x64\bin

Dynamic Linq Predicate throws “Unsupported Filter” error with C# MongoDB Driver

a 夏天 提交于 2019-12-10 20:18:49
问题 I have been trying to pass in a dynamic list of Expressions to a MongoDB C# Driver query using Linq ... This method works for me with regular Linq queries against an ORM, for example, but results in an error when applied to a MongoDB query ... (FYI: I am also using LinqKit's PredicateBuilder) // // I create a List of Expressions which I can then add individual predicates to on an // "as-needed" basis. var filters = new List<Expression<Func<Session, Boolean>>>(); // // If the Region

Does order matter in bson_iter_find in mongo c driver

♀尐吖头ヾ 提交于 2019-12-08 02:27:44
问题 I am using mongo c driver 1.1 with mongo version 3.0. Libbson version 1.1. I am using an iterator to look for certain fields in a document. The following code only works when "fieldA" is above "fieldB" in mongodb. If i change the order bson_iter_find returns false. if(bson_iter_find(&iterator,"fieldA")){ pintf("fieldA"); } if(bson_iter_find(&iterator,"fieldB")){ pintf("fieldB"); } In older versions of the libbson(0.4) I was able to use bson_find(), to look for fields in a doc. Is there

Does order matter in bson_iter_find in mongo c driver

眉间皱痕 提交于 2019-12-06 04:39:16
I am using mongo c driver 1.1 with mongo version 3.0. Libbson version 1.1. I am using an iterator to look for certain fields in a document. The following code only works when "fieldA" is above "fieldB" in mongodb. If i change the order bson_iter_find returns false. if(bson_iter_find(&iterator,"fieldA")){ pintf("fieldA"); } if(bson_iter_find(&iterator,"fieldB")){ pintf("fieldB"); } In older versions of the libbson(0.4) I was able to use bson_find(), to look for fields in a doc. Is there something similar i can use in the new libbson library? Link to new libbson library https://api.mongodb.org

cannot compile mongo-c-driver example

放肆的年华 提交于 2019-12-05 06:52:05
I try to write simple mongo c client. Source file (a.c): #include <stdio.h> #define MONGO_HAVE_STDINT #include <mongo.h> void mongo_init_c(mongo *con) { mongo_init(con); } int main() { return 0; } And i try to compile it with: gcc -I/usr/local/include -L/usr/local/lib -lmongoc a.c But get an error: a.c:(.text+0xd): undefined reference to `mongo_init' Files /usr/local/include/mongo.h and /usr/local/lib/libmongoc.so exists How can I correctly compile a.c? p.s. mongo-2.0.4, gcc-4.6, mongo-c-driver - pulled from github update $ nm /usr/local/lib/libmongoc.so | grep init 000034e0 T _init 0000dd10 T