'Problem at inserting datas from Discord.js to MySQL database

I got another issue with my discord.js bot. but this time, it's about the database. I'm using WampServer app to create a DataBase in MySQL language in there. and by watching some tutorials and stuff I could finally connect that database to my bot. But now I need to insert some data to my database, so I tried to do that when the bot joins a server, it'll insert the ID of the server + the ID of the owner account to my database:

client.on('guildCreate', async (guild) => {
try {
      await connection.query(
            `INSERT INTO Guilds VALUES('${guild.Id}', '${guild.OwnerId}')`
      )
      await connection.query(
            `INSERT INTO GuildConfigurable (guildId) VALUES ('${guild.Id}')`
      )
    } catch (err) {
        console.log("\x1b[31m" + "Problem at inserting the data to the database:\n"+ "\x1b[0m" + err)
    }
}

But what I get in the terminal is:

Problem at inserting the data to the database:
TypeError: connection.query is not a function.

I don't really know what the problem is, also I have already defined that what the "connection" variable is, it's requiring the db.js file that has the connecting process to my database inside of it. So this kinda has to work, but it doesn't :(

can somebody help me with it plz???



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source