Skip to content

Instantly share code, notes, and snippets.

@sharpred
Created July 18, 2012 13:23
Show Gist options
  • Save sharpred/3136191 to your computer and use it in GitHub Desktop.
Save sharpred/3136191 to your computer and use it in GitHub Desktop.
mongo update attachments metadata
<?php
$mongoDB = new Mongo();
$database = $mongoDB->selectDB("BVS");
$collection = $database->createCollection('fs.files');
$search = array("metadata.formdata.claimid" => "4");
$replace = array('$set'=>array("metadata.formdata.mynewfield" => "wibble")); // note use of single quotes around $set. This is compulsory
$multiple = array("multiple" => true); // used to update all records that match default is false (update first record only)
$collection->update($search, $replace, $multiple);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment