mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-05-31 09:46:39 +02:00
api: Update graphql schema
This commit is contained in:
parent
39f721101e
commit
4f587820d1
9 changed files with 578 additions and 200 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"log"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -235,7 +236,12 @@ func GetUserByID(id primitive.ObjectID) (*model.DBUser, error) {
|
|||
func GetUserByUsername(username string) (*model.DBUser, error) {
|
||||
db := DbClient.Database(viper.GetString("bot.mongo.database"))
|
||||
|
||||
res := db.Collection(viper.GetString("bot.mongo.collection.users")).FindOne(context.TODO(), bson.D{{"username", username}})
|
||||
regexPattern := "^" + regexp.QuoteMeta(username) + "$"
|
||||
|
||||
res := db.Collection(viper.GetString("bot.mongo.collection.users")).FindOne(context.TODO(), bson.D{{"username", primitive.Regex{
|
||||
Pattern: regexPattern,
|
||||
Options: "i",
|
||||
}}})
|
||||
if res.Err() != nil {
|
||||
return nil, res.Err()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue