add AddUserInChat

This commit is contained in:
2022-04-25 02:57:53 +07:00
parent c4a39056d8
commit 9d5b5c2a2f
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ func AddChat(chatID int64) error {
collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName)
result := collection.FindOne(ctx, bson.E{Key: "chat_id", Value: chatID})
result := collection.FindOne(ctx, bson.M{"chat_id": chatID})
if result.Err() == mongo.ErrNoDocuments {
if _, err := collection.InsertOne(ctx, &chatDTO{ChatID: chatID}); err != nil {
return err
@@ -56,7 +56,7 @@ func AddUserInChat(chatID int64, username string) error {
collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName)
_, err = collection.UpdateOne(
ctx,
bson.E{Key: "chat_id", Value: chatID},
bson.M{"chat_id": chatID},
bson.M{"addToSet": bson.M{"users": username}},
)
return err