1

i have this code

var new_styles = ["XEP02" ,"XEP65" ,"XEPB01" ,"XEPB03" ,"XN06" ,"XN14" ,"XN73"];

for( var i = 0; i < new_styles.length; i++ ) {
    var style_name = [i];
    var full_length = "/assets/full_length/low_res/" + style_name + ".jpg";
    var cropped =  "/assets/cropped/low_res/" + style_name + ".jpg";
    db.styles.update({"_id": style_name},  {"$push" : {"images.full_lenght": full_length, "images.cropped": cropped }});
}

when i run it on the mongo console, it does not seem to work, where as

db.styles.update({"_id": "XEP02"},  {"$push" : {"images.full_lenght": "/assets/full_length/low_res/XEP02.jpg", "images.cropped": "/assets/cropped/low_res/XEP02.jpg"}});

works

what am i missing?

1
  • 2
    style_name = [i] what are you trying to do with that? Commented Nov 23, 2015 at 16:13

1 Answer 1

1

There is a bug in your for loop, it currently queries for "_id":0,"_id":1,etc. You need to change var style_name = [i] to this:

 var style_name = new_styles[i];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.