mongo常用sql

区间查询:
db.getCollection('repay_batch_info').find({"batch_no":{"$gt":"mnwp2pt005","$lt":"mnwp2pt107"}})

and查询:
db.getCollection('loan_instruction').find({$and:[{"channel_code" : "xmjr"},{"status" : "SUCCESS"}]})

模糊查询:
db.getCollection('request_log').find({"url" : {$regex:/LP10001/}})

 

联表查寻:

db.apply.aggregate([
{
$lookup:
{
from: "request_log",
localField: "apply_id",
foreignField: "apply_id",
as: "request_log"
}
},
{ $match : {"request_log.url" : {$regex:/LP10001/}} }
])

对应T-sql:

select * from apply a left join request_log r on a.apply_id = r.apply_id where r.request_log.url like '%LP10001%'

posted @ 2019-07-09 11:39  carlvine  阅读(231)  评论(0编辑  收藏  举报