Beispiel #1
0
        ///<inheritdoc cref="IDatabaseEngine.SaveUserToGuild(DatabaseUser, ulong, bool)"/>
        public DatabaseUser SaveUserToGuild(DatabaseUser user, ulong guildId, bool log = true)
        {
            if (log)
            {
                Core.Logger.LogGenericMessage($"[LiteDb] SAVED User {user.Id} TO {guildId}");
            }
            var _db = liteDatabase.GetCollection <DatabaseUser>($"{guildId}-users");

            _db.Upsert(user);
            return(user);
        }
Beispiel #2
0
        ///<inheritdoc cref="IDatabaseEngine.SaveUserToGuild(DatabaseUser, ulong, bool)"/>
        public DatabaseUser SaveUserToGuild(DatabaseUser user, ulong guildId, bool log = true)
        {
            if (log)
            {
                Core.Logger.LogGenericMessage($"[Mongo] SAVED User {user.Id} TO {guildId}");
            }

            var _userDb     = GetDatabaseFromGuildId(guildId);
            var _collection = _userDb.GetCollection <DatabaseUser>("users");

            if (_collection.Find(u => u.Id == user.Id).Any())
            {
                _collection.FindOneAndReplace(u => u.Id == user.Id, user);
            }
            else
            {
                _collection.InsertOne(user);
            }
            return(user);
        }