http://www.perlmonks.org?node_id=989864


in reply to Re^4: MongoDB replacing an array
in thread MongoDB replacing an array

Okay, let's look at what you have.

The MongoDB::Collection docs show that update takes three hash references (\%criteria, \%object and \%options).

$col->update( { "host" => $host }, { '$set' => { "timestamp" => [ @new ] } }, { 'multiple' => 1, 'safe' => 1 } ) || die "$!";

Your criteria is simply host = $host. Your object should set timestamp to the contents of @new. Your options include multiple which tells it to update all matching records and safe which causes it to croak on errors (so the || die you have is superfluous).

Are you getting any errors or do the records just end up empty?

Based on the docs, it looks right. So what's missing? We don't know. Without seeing more of the code, I don't think anyone will be able to help you.