1
我有這樣的代碼MongoDB的更新命令行的多條記錄
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 }});
}
當我蒙戈控制檯上運行它,它似乎並沒有工作,那裏的
db.styles.update({"_id": "XEP02"}, {"$push" : {"images.full_lenght": "/assets/full_length/low_res/XEP02.jpg", "images.cropped": "/assets/cropped/low_res/XEP02.jpg"}});
工作
我在想什麼?
'style_name = [i]'你想用那個做什麼? –