柳暗花明笔记

    从Mongo里导产品数据的方式

    所属分类:[ linux&mysql ] 猫哲学家 发表于:2014-05-03 15:19 浏览:521

    db.Product.find().forEach(function(product){
    var category=new Array();
    var categoryName=new Array();

    if(product.CategoryPath.length>0){
    category=product.CategoryPath[0].split('-');
    }

    category.forEach(function(c){
    var temp=db.Category.find({"_id":parseInt(c)});
    categoryName.push(temp[0].Attributes.en.ShortHeadline);
    });

    if(categoryName.length==3){
    print(product.Common.en.ShortHeadline,"\t",product._id,"\t","http://www.moviemyshare.com/p/"+product._id,"\t","http://img.dxcdn.com/productimages/"+product.ImageSet.small[0],"\t",categoryName[0],"\t",categoryName[1], "\t",categoryName[2],"\t",product.Price.Value);
    }

    if(categoryName.length==2){
    print(product.Common.en.ShortHeadline,"\t",product._id,"\t","http://www.moviemyshare.com/p/"+product._id,"\t","http://img.dxcdn.com/productimages/"+product.ImageSet.small[0],"\t",categoryName[0],"\t",categoryName[1],"\t"," ","\t",product.Price.Value);
    }

    if(categoryName.length==1){
    print(product.Common.en.ShortHeadline,"\t",product._id,"\t","http://www.moviemyshare.com/p/"+product._id,"\t","http://img.dxcdn.com/productimages/"+product.ImageSet.small[0],"\t",categoryName[0],"\t"," ","\t"," ","\t",product.Price.Value);
    }

    if(categoryName.length==0){
    print(product.Common.en.ShortHeadline,"\t",product._id,"\t","http://www.moviemyshare.com/p/"+product._id,"\t","http://img.dxcdn.com/productimages/"+product.ImageSet.small[0],"\t"," ","\t"," ","\t"," ","\t",product.Price.Value);
    }

    })

     

    2017-07-12 批量把http改为https

    db.studios_url.find().forEach(function(item){
    item.url = item.url.replace("http://", "https://");
    db.collection.save(item);
    })

    标签: mongodb 
    上一编文章 可以分享图片的网址 下一编文章 linux svn 创建分支和合并分支
    最近文章
    发表评论