mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
more powerful PageFindUserWithKeyword
This commit is contained in:
parent
d79a313000
commit
3919eebc96
@ -102,12 +102,12 @@ func (u *UserMgo) PageFindUserWithKeyword(ctx context.Context, level1 int64, lev
|
|||||||
userConditions := []bson.M{}
|
userConditions := []bson.M{}
|
||||||
if userID != "" {
|
if userID != "" {
|
||||||
// Use regex for userID
|
// Use regex for userID
|
||||||
regexPattern := primitive.Regex{Pattern: userID, Options: "i"} // 'i' for case-insensitive matching
|
regexPattern := primitive.Regex{Pattern: userID} // 'i' for case-insensitive matching
|
||||||
userConditions = append(userConditions, bson.M{"user_id": regexPattern})
|
userConditions = append(userConditions, bson.M{"user_id": regexPattern})
|
||||||
}
|
}
|
||||||
if userName != "" {
|
if userName != "" {
|
||||||
// Use regex for userName
|
// Use regex for userName
|
||||||
regexPattern := primitive.Regex{Pattern: userName, Options: "i"} // 'i' for case-insensitive matching
|
regexPattern := primitive.Regex{Pattern: userName} // 'i' for case-insensitive matching
|
||||||
userConditions = append(userConditions, bson.M{"nickname": regexPattern})
|
userConditions = append(userConditions, bson.M{"nickname": regexPattern})
|
||||||
}
|
}
|
||||||
query["$and"] = append(query["$and"].([]bson.M), bson.M{"$or": userConditions})
|
query["$and"] = append(query["$and"].([]bson.M), bson.M{"$or": userConditions})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user