From 8d5d54af33b5e10b4eb382427bf44be115de6714 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Wed, 10 Jan 2024 18:24:24 +0800 Subject: [PATCH] fix: fix the mongo search error --- pkg/common/db/mgo/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index 892a42003..574689fc1 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -82,7 +82,7 @@ func (u *UserMgo) PageFindUser(ctx context.Context, level int64, pagination pagi } func (u *UserMgo) GetAllUserID(ctx context.Context, pagination pagination.Pagination) (int64, []string, error) { - return mgoutil.FindPage[string](ctx, u.coll, bson.M{}, pagination, options.Find().SetProjection(bson.M{"user_id": 1})) + return mgoutil.FindPage[string](ctx, u.coll, bson.M{}, pagination, options.Find().SetProjection(bson.M{"_id": 0, "user_id": 1})) } func (u *UserMgo) Exist(ctx context.Context, userID string) (exist bool, err error) { @@ -90,7 +90,7 @@ func (u *UserMgo) Exist(ctx context.Context, userID string) (exist bool, err err } func (u *UserMgo) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) { - return mgoutil.FindOne[int](ctx, u.coll, bson.M{"user_id": userID}, options.FindOne().SetProjection(bson.M{"global_recv_msg_opt": 1})) + return mgoutil.FindOne[int](ctx, u.coll, bson.M{"user_id": userID}, options.FindOne().SetProjection(bson.M{"_id": 0, "global_recv_msg_opt": 1})) } func (u *UserMgo) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {