Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
710 views
in Technique[技术] by (71.8m points)

go - How to perform subquery with MongoDB

I have the following script which is valid Aggregation statement with a subquery for $nin clause. I found it's hard to do it with Go mongo driver without first performing the sub query db.ble2.distinct("_id") from Go code, how to do it at once with go driver?

db.ble.aggregate([
    { "$match": {
        "_id": { 
            "$nin": db.ble2.distinct("_id")
        }
    }},
    {"$limit": 20}
])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...