Skip to content

Instantly share code, notes, and snippets.

@pettomartino
Last active December 12, 2015 08:08
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 pettomartino/4741391 to your computer and use it in GitHub Desktop.
Save pettomartino/4741391 to your computer and use it in GitHub Desktop.
var cursor = db.places.find();
while (cursor.hasNext()) {
var x = cursor.next();
x['source']['url'].replace('aaa', 'bbb'); // is this correct?
db.foo.update({_id : x._id}, x);
}
var cursor = db.places.find();
while (cursor.hasNext()) {
var x = cursor.next();
for(var i=0; i < x["suites"].length; i++){
var fotos = Array();
for(var k=0; k < x["suites"][i]["fotos"].length; k++){
fotos[k] = {"fotos" : x["suites"][i]["fotos"][k] };
}
x["suites"][i]["fotos"] = fotos;
}
db.places.update({_id : x._id}, x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment