Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: MongoDB replacing an array

by Khen1950fx (Canon)
on Aug 26, 2012 at 03:17 UTC ( #989777=note: print w/replies, xml ) Need Help??

in reply to MongoDB replacing an array

This is just a general idea. You'll probably need to adjust the validation options in order for it to work.
#!/usr/bin/perl use strict; use warnings; use MongoDB; use DateTime; my $today = DateTime->now; my $stamp = DateTime->now->set( 'timestamp' => $today->day, ); my $database = '/tmp/collection'; $database->update( {'host' => ''}, {'set' => {"timestamp" => 'new'}}, {'multiple' => 1, 'safe' => 1} );

Replies are listed 'Best First'.
Re^2: MongoDB replacing an array
by neilwatson (Priest) on Aug 26, 2012 at 13:13 UTC

    New quoted without an array '@'? In my original example '@new' is any array.

    Neil Watson

Re^2: MongoDB replacing an array
by Mr. Muskrat (Canon) on Aug 27, 2012 at 18:42 UTC

    I can't find any documentation to indicate that there is any sort of validation that happens during an insert or update of a generic column.

Re^2: MongoDB replacing an array
by chchow (Initiate) on May 16, 2014 at 05:43 UTC
    I believe this is correct: $col->update( { "host" => $host }, { '$set' => { "timestamp" => \@new } }, { 'multiple' => 1, 'safe' => 1 } ) || die "$!"; It should be a array ref instead.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989777]
[choroba]: and in fact, you don't push into the target repo, you push into your branch of your fork
[choroba]: the maintainer of the upstream repo than "merges" the pull request, i.e. they pull from your fork into the upstream
[Discipulus]: ' i.e. you asked them to pull from your repo' =~ I (subj) want to push
[Discipulus]: chorobayour words are reasonable
[choroba]: I'm just repeating some else's words as I remembered them after having asked the same question
[choroba]: s/some/someone/
Discipulus what a pity all people do not speak only in eatalian..
[choroba]: we'd need video calls more often :)
[Discipulus]: i still suspect english has some logical 'curvature/ crookedness' that has and will have a big impact over programming

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-05-27 20:17 GMT
Find Nodes?
    Voting Booth?