Preface
Reserved
Content
MongoDB C++ 驱动查询参数遇到的问题
bsoncxx/builder/stream/value_context.hpp:69: error: call of overloaded ‘append(unsigned int&)’ is ambiguous
_core->append(std::forward(t));
这是MongoDB C++ driver:mongocxx 设计上是一个问题,int类型只支持int32和int64类型,而我们使用了unsigned int的一个别名,所以导致了报错,转型int就可以了。
1 | using bsoncxx::builder::stream::document; |
参考
bsoncxx::builder::core::append of unsigned int
expected element type k_int32
MongDB 中存放的 NumberLong 对应的是 int64;
普通整型对应的是 int32;
如果使用 get_int32/int64 去取不对应的数据的话,会导致报以上错误。
mongorestore
1 | mongorestore /h 192.168.2.160 /port 27017 /dir currentdir -d targetdatabase /bypassDocumentValidation |
这个是Windows上面的操作,具体的可以参考:
1 | mongorestore --help |
mongoshell 执行js脚本
1 | mongo 192.168.0.200/test e:/test.js |
这个是不带验证的,验证的要另加。
以下是一段数据整理的脚本,数据量多的话可以利用 cursor 的分页功能:
1 | var s = db.getMongo().startSession() |
以下是建库建集合的脚本:
1 | var conn = new Mongo('192.168.0.200:27017'); |