mongodb 2019-04-24

db.getCollection('d_snc_product_tc').find({"original_data.exceptDate" : { ne: []}}) 查询tongcheng_product中original_data下exceptDate 不为空
db.getCollection('d_snc_product_tc').find({"sup_product_id": {"$exists": true}}) 查询tongcheng_product 中存在sup_product_id的

lookup:连表查询
db.getCollection('d_snc_product_tc').aggregate([
{$lookup: {
from: "d_snc_product_price_calendar_tc",
localField: "sup_product_id",
foreignField: "sup_product_id",
as: "member"
}
},
])

from: "要连接的表",
localField: "当前Collection中需要连接的字段",
foreignField: "外连Collection中连接查询的字段",
as: "把获取到的的值赋值给这个字段

你可能感兴趣的:(mongodb 2019-04-24)