https://github.com/xyz347/mongoxclient
利用x2struct对mongo-cxx-driver的一个简单封装。可以像golang一样直接操作结构体。只有基本接口,还不是很完备。
https://github.com/xyz347/mongoxclient
cpp golang mongodb-driver wrapper x2struct
Last synced: 9 months ago
JSON representation
利用x2struct对mongo-cxx-driver的一个简单封装。可以像golang一样直接操作结构体。只有基本接口,还不是很完备。
- Host: GitHub
- URL: https://github.com/xyz347/mongoxclient
- Owner: xyz347
- Created: 2018-11-03T12:16:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-18T01:08:20.000Z (almost 3 years ago)
- Last Synced: 2025-04-01T07:42:26.391Z (about 1 year ago)
- Topics: cpp, golang, mongodb-driver, wrapper, x2struct
- Language: C++
- Size: 739 KB
- Stars: 4
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mongoxclient
利用[xpack](https://github.com/xyz347/xpack)对mongo-cxx-driver的一个简单封装,可以像golang一样直接操作结构体。只有基本接口,还不是很完备。**需要C++11支持**
-----
## 范例
范例请参考[main.cpp](test/main.cpp),里面有各个接口的使用举例
## xpack::BsonBuilder
- 用于简化一些bson数据的构造,能用json来描述bson数据
- 名字比较长,这里用using bb = xpack::BsonBuilder;举例
- 简单用法是bb::En(string, args...)
- string是一个类似于json的字符串,里面用单引号代替双引号
- 里面用问号表示一个变量,问号后面可以加一个变量名称方便阅读,比如?uid
- args的数量应该和问号的数量一致,对应key的参数必须是std::string/const char[]类型
- 范例:`bb::En("{'_id':?}", uid)`
- 对于比较复杂且会复用的builder,建议定义成static变量,后面调用Encode是线程安全的