mongodb://USER:SECRET@appname-shard-00-00-tlxyp.mongodb.net:27017,appname-shard-00-01-tlxyp.mongodb.net:27017,appname-shard-00-02-tlxyp.mongodb.net:27017/test?ssl=true&replicaSet=appname-shard-0&authSource=admin
参数:
scoringSystem
/home/myUser/IdeaProjects/app/scoring-system.json
[1] 23452
[2] 23453
2017-10-17T20:00:28.633+0200 no collection specified
2017-10-17T20:00:28.633+0200 using filename '' as collection
2017-10-17T20:00:28.633+0200 error validating settings: invalid collection name: collection name cannot be an empty string
2017-10-17T20:00:28.633+0200 try 'mongoimport --help' for more information
--collection: command not found
[1]- Exit 1 mongoimport --uri mongodb://(...output omitted...)?ssl=true
[2]+ Done replicaSet=Wamsteady-shard-0
这导致:
mongoimport --version
mongoimport version: r3.4.9
git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
Go version: go1.7
os: linux
arch: amd64
compiler: gc
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
我不明白mongoimport如何找不到命令“--collection”,因为它是documented here的有效参数。
有什么问题?
#include <string>
#include <functional>
#include <iostream>
struct WrapperHelp
{
template
< typename L
, typename Tuple
, std::size_t... Is
, typename... Ts
>
static auto apply(L&& l, Tuple t, std::index_sequence<Is...>, Ts&&... ts)
-> decltype(l(std::get<Is>(t)...))
{
return l(std::get<Is>(t)...);
}
template
< typename L
, typename Tuple
, std::size_t... Is
, typename T1
, typename... Ts
>
static auto apply(L&& l, Tuple t, std::index_sequence<Is...>, T1&& t1, Ts&&... ts)
-> decltype(WrapperHelp::apply(std::forward<L>(l), std::forward_as_tuple(std::get<Is>(t)..., t1), std::make_index_sequence<sizeof...(Is) +1 >(), ts...))
{
return WrapperHelp::apply(std::forward<L>(l), std::forward_as_tuple(std::get<Is>(t)..., t1), std::make_index_sequence<sizeof...(Is) + 1>(), ts...);
}
};
template<typename L>
struct OptionalWrapper {
public:
OptionalWrapper(L l) : lambda{std::move(l)} {}
template<typename... Ts>
void operator()(Ts&&... ts) const
{
WrapperHelp::apply(lambda, std::tuple<>(), std::index_sequence<>(), std::forward<Ts>(ts)...);
}
private:
L lambda;
};
template<typename L>
auto makeOptionalWrapper(L l) { return OptionalWrapper<L>{std::move(l)}; }
template<class F>
void loadData(OptionalWrapper<F>&& callback)
{
std::string body = "body";
std::string subject = "subject";
std::string header = "header";
double lol = 2.0;
callback(body, subject, header, lol);
}
template<typename L>
void loadData(L callback)
{
loadData(makeOptionalWrapper(std::move(callback)));
}
int main() {
//apply(std::tuple<double>(2), std::tuple<double>(2));
loadData([](auto&& body) {
std::cout << body << std::endl;
});
loadData([](auto&& body, auto&& subject) {
std::cout << body << " " << subject << std::endl;
});
loadData([](auto&& body, auto&& subject, auto&& header) {
std::cout << body << " " << subject << " " << header << std::endl;
});
loadData([](auto&& body, auto&& subject, auto&& header, auto&& lol) {
std::cout << body << " " << subject << " " << header << " " << lol << std::endl;
});
return 0;
}
答案 0 :(得分:3)
您必须引用uri
参数。它包含一个&
,由您在mongoimport
中运行的任何内容解释。
所以,替换这个......
mongoimport --uri mongodb://USER:SECRET@appname-shard-00-00-tlxyp.mongodb.net:27017,appname-shard-00-01-tlxyp.mongodb.net:27017,appname-shard-00-02-tlxyp.mongodb.net:27017/test?ssl=true&replicaSet=appname-shard-0&authSource=admin --collection scoringSystem --file /home/myUser/IdeaProjects/app/scoring-system.json
......用这个:
mongoimport --uri "mongodb://USER:SECRET@appname-shard-00-00-tlxyp.mongodb.net:27017,appname-shard-00-01-tlxyp.mongodb.net:27017,appname-shard-00-02-tlxyp.mongodb.net:27017/test?ssl=true&replicaSet=appname-shard-0&authSource=admin" --collection scoringSystem --file /home/myUser/IdeaProjects/app/scoring-system.json