Skip to content

Instantly share code, notes, and snippets.

@phillipadsmith
Created March 5, 2013 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipadsmith/5139387976327b99b93b to your computer and use it in GitHub Desktop.
Save phillipadsmith/5139387976327b99b93b to your computer and use it in GitHub Desktop.
# Mongo query
> db.links.update({ _id: ObjectId("...") }, { $push: { tweets: { text: 'A test string' } } })
# Mango ...?
my $url_obj = $mango->db( 'fomo' )->collection( 'links' )->find_one( $query );
if ( $url_obj ) {
say "I'm updating..." . $url_obj->{'_id'};
my $update = {
'_id' => 'ObjectId("' . $url_obj->{'_id'} . '")',
'$push' => {
'tweets' => $tweet
},
};
say Dumper( $update );
my $result = $mango->db( 'fomo' )->collection( 'links' )->update( $update );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment