Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Updated Albums to exclude deleted mediaitems
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuomkar committed Nov 26, 2021
1 parent 4901574 commit 8f201ed
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/internal/graph/resolvers/album.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@ func (r *albumResolver) MediaItems(ctx context.Context, obj *models.Album, page

albumID, _ := primitive.ObjectIDFromHex(obj.ID)

lookupStage := bson.D{{Key: "$match", Value: bson.D{
matchStage := bson.D{{Key: "$match", Value: bson.D{
{Key: "_id", Value: albumID},
}}}
matchStage := bson.D{{Key: "$lookup", Value: bson.D{
lookupStage := bson.D{{Key: "$lookup", Value: bson.D{
{Key: "from", Value: "mediaitems"},
{Key: "localField", Value: "mediaItems"},
{Key: "foreignField", Value: "_id"},
{Key: "let", Value: bson.D{
{Key: "mediaItems", Value: "$mediaItems"},
}},
{Key: "pipeline", Value: bson.A{
bson.D{{Key: "$match", Value: bson.D{
{Key: "$expr", Value: bson.D{{Key: "$cond", Value: bson.A{
bson.D{{Key: "$ne", Value: bson.A{"$deleted", true}}},
bson.D{{Key: "$in", Value: bson.A{"$_id", "$$mediaItems"}}},
}}}},
}}},
}},
{Key: "as", Value: "mediaItem"},
}}}

Expand Down

0 comments on commit 8f201ed

Please sign in to comment.