Skip to content

Commit

Permalink
fix(api): getAllRestock was giving deleted restock
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptTF committed Apr 29, 2024
1 parent cb1593e commit ed1d6fe
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions backend/internal/db/mongo/restock_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ func (b *Backend) GetAllRestocks(ctx context.Context, page uint64, size uint64)
ctx, cancel := b.TimeoutContext(ctx)
defer cancel()

filter := bson.M{}
filter := bson.M{
"$or": []bson.M{
{
"deleted_at": bson.M{
"$exists": false,
},
},
{
"deleted_at": nil,
},
},
}

// Get "size" restocks from "page" using aggregation
var restocks []*models.Restock
Expand All @@ -72,7 +83,18 @@ func (b *Backend) CountAllRestocks(ctx context.Context) (uint64, error) {
ctx, cancel := b.TimeoutContext(ctx)
defer cancel()

filter := bson.M{}
filter := bson.M{
"$or": []bson.M{
{
"deleted_at": bson.M{
"$exists": false,
},
},
{
"deleted_at": nil,
},
},
}

count, err := b.db.Collection(RestocksCollection).CountDocuments(ctx, filter)
if err != nil {
Expand Down

0 comments on commit ed1d6fe

Please sign in to comment.