我正在尝试使用perl从mongodb中获取数据,但是变量$people
的值未定义
my $client = MongoDB::MongoClient->new(host =>
'mongodb://xxx.xxx.xxx.xxx',port=>27017, username => 'xxxx',
password => 'xxxx');
my $db = $client->get_database("xxx");
my $collection = $db->get_collection("xxx");
my $people = $collection->find_one({"transactionid" => $id});
while (my $p = $people->next) {
print Dumper $p;
}
我想获取此数据:
{
"_id" : ObjectId("5c453500e2fb4adc98e9fa84"),
"transactionid" : NumberLong(45282),
"transactionbillerid" : NumberLong(43137),
"requesttime" : ISODate("2019-01-21T02:57:04.923Z"),
"requestmessage" : "xxxxxxxx",
"responsetime" : ISODate("2019-01-21T02:57:05.236Z"),
"responsemessage" : "xxx"
}
任何建议,我的代码有问题吗?
答案 0 :(得分:1)
我认为您误解了for (int i = 0; i < ((ViewGroup) shiftFragment).getChildCount(); i++) {
View child = ((ViewGroup)shiftFragment).getChildAt(i);
visibilityMap.put(child, child.getVisibility());
child.setVisibility(View.VISIBLE);
}
shiftFragment.post(new Runnable() {
@Override
public void run() {
final ViewGroup viewGroup = helpUtils.getHelpViewGroup(targets);
if (firstTime) {
((FrameLayout)helpView).addView(viewGroup);
}
helpView.setVisibility(View.VISIBLE);
);
返回的值。名称中有一个很大的线索,但是find_one()
返回一条记录,而不是迭代器。
很显然,我无权访问您的数据,因此无法确认,但是我希望您可以通过运行以下代码来获得所需的内容:
find_one()