mongodb tips

阅读 47

2022-01-26

导出数据

mongoexport卡住不能导出数据时,可以加上--forceTableScan选项来强制扫描表。

替换字段内容

db.bl.find({}).forEach( 
  function(item) {
    item.cate = String(item.cate).replace(',','>') ;
    item.cate_id = String(item.cate_id).replace(',','>') ;
    db.bl2.save(item);
  } 
 );

查找null类型

  • 字段存在且值为null:{ "field": { $type: 10 } }
  • 字段不存在:{ "field": { $exists: false } }
  • 同时查找以上两种类型:{ "field":null }
  • 同时过滤掉以上两种类型:{ "field":{ $ne : null } }

精彩评论(0)

0 0 举报