MongoDB Aggregate нужен совет

Есть 2 коллекции, hash_collection и task_to_hash, необходимо создать агрегат, в который войдут все документы из hash_collection, _id которых нет в документах task_to_hash в поле "hash", голову сломал уже.

filter := bson.D{{}}
opt := options.Aggregate().SetAllowDiskUse(true)
lookupStage := bson.D{{"$lookup", bson.D{{"from", "task_to_hash"}, {"localField", "_id"}, {"foreignField", "hash"}, {"as", "exist"}}}}
    matchStage := bson.D{{"$match", bson.D{{"exist", bson.D{{"$eq", bson.A{}}}}}}}
    limitStage := bson.D{{"$limit", 10}}
    showLoadedCursor, err := hash_collections.Aggregate(context.TODO(), mongo.Pipeline{lookupStage, matchStage, limitStage}, opt)
    if err != nil {
        panic(err)
    }

Буду благодарен за совет.


Ответы (0 шт):