From efff638ab580da7da8b63e46cbddad6fa8a951c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Wed, 15 Jan 2025 15:16:58 +0800 Subject: [PATCH] fix: query wihout parent_id all result will come out --- pkg/repository/comment.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/repository/comment.go b/pkg/repository/comment.go index 3789b4b..a54101d 100644 --- a/pkg/repository/comment.go +++ b/pkg/repository/comment.go @@ -110,7 +110,12 @@ func (repo *CommentRepository) ListComments(ctx context.Context, req repository. filter := bson.M{} if req.ParentID != nil { filter["parent_comment_id"] = req.ParentID + } else { + filter["parent_comment_id"] = bson.M{ + "$in": []interface{}{"", nil}, + } } + if req.ReferenceID != nil { filter["reference_id"] = req.ReferenceID }