我正在使用PERL和MongoDB。我的连接正常,我可以使用特定的record_id键找到一条记录。
但是我无法找到属于特定用户的开放记录。我也无法显示Owner.Name值。
my $count = 0;
my $records = $dbc->find({ "Owner.Name" => {'$eq' => "Joe Bloggs"}, IsClosed => {'$eq' => 0 }});
while(my $record=$records->next)
{
foreach my $key (keys %$record )
{
my $val=$record->{$key};
print "$key->$val\n";
$count++;
}
print "Owner Name: ";
print $record->{"Owner->Name"};
print "The number of cases is $count\n";
print "\n";
}
print "The number of cases is $count\n";
当找到有效案例(此处未显示)时,Owner.Name值显示为空字符串。在上面的代码中,while循环从不执行,因此count保持为0。
谢谢!