Skip to content

Instantly share code, notes, and snippets.

@andresmgsl
Forked from archector/mongoupdate
Last active August 29, 2015 14:22
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 andresmgsl/6ab6871db9f11a7d48e3 to your computer and use it in GitHub Desktop.
Save andresmgsl/6ab6871db9f11a7d48e3 to your computer and use it in GitHub Desktop.
db.images.find({}).forEach(function(doc){
var regexp = /(.*)\.[^.]+$/;
var thumbName = doc.name.split('.').reverse().slice(1);
db.images.update(
{number:doc.number},
{ $set:
{"path": {
"url" : "assets/images/users/" + doc.username + "/pieces/" + doc.number + "/" + doc.name,
"thumb": "assets/images/users/" + doc.username + "/pieces/" + doc.number + "/" + thumbName + "_thumb.jpg"}
}
},
{upsert:true}
);
})
db.getCollection('users').update({},{$rename: {"role": "roles"}},false,true)
db.getCollection('images').update({},{$set: {"checked": true}},false,true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment