我有这个结构:
{
"user" => "xxxx",
"position" =>
{
"A1" => { "state" => 'It', region=>"LOM" etc etc..},
"A2" => { .... },
"A3" => { .... },
....
"An" => { .. }
}
}
插入没问题。但更新返回此错误:
not a reference at /usr/local/lib/perl/5.12.4/MongoDB/Collection.pm line 376
我的更新是:
$tbl->update({
{ _id => MongoDB::OID->new(value => "$id") },
{ '$set' =>
{
"position" =>
{
"A1" => { "state" => "En" }
}
}
}
});
哪里错了? THKS!
答案 0 :(得分:1)
语法更新
update (\%criteria, \%object, \%options?)
MongoDB :: Collection方法更新
sub update {
my ($self, $query, $object, $opts) = @_;
...
}
但您只传递了1个参数。
$tbl->update(
{ # 1st anonymous hash
{ _id => MongoDB::OID->new(value => "$id") },
{ '$set' => {
"position" => {
"A1" => { "state" => "En" }
}
}
}
});
所以我建议你弄清楚方法更新的传递参数。