Database query question

Hey,

 

I am currently using the Oxide.Core.Database query and I just saw that it is async.

 

For example I need an entry out of the DB and I start a query I find an entry and now I need the entry send back as a return. (see example)

bool has_user_already_db_entry(BasePlayer player)
        {
            string sqlQuery = "SELECT `steam64ID` FROM users WHERE steam64ID = @0";
            Sql selectCommand = Oxide.Core.Database.Sql.Builder.Append(sqlQuery, player.IPlayer.Id);

            bool player_found = false;

            sqlLibrary.Query(selectCommand, DB, list =>
            {
                if (list != null)
                {
                    player_found = true;
                }
            });

            return player_found;
        }

 

I always get false since the query isn't finished yet.

Am I missing something?

 

Best regards

you need a timer or a NextTick before checking if the list is null, inside Query()

I'd personally do a callback action.