How do I check if a data exists in a MySQL database? I have already managed to get the data but I just want to know how to do it: If this data does not exist.
My current code:
connection.query(`select builduhcelo from practiceplayers where uuid = '${uuid}'`, function (errbu, resultbu) {
if(errbu) throw errbu;
connection.query(`select nodebuffelo from practiceplayers where uuid = '${uuid}'`, function (errnd, resultnd) {
if(errnd) throw errnd;
connection.query(`select ironbuilduhcelo from practiceplayers where uuid = '${uuid}'`, function (erribu, resultibu) {
if(erribu) throw erribu;
let embed = new Discord.RichEmbed()
.setAuthor(`Elorion.net`, `https://image.noelshack.com/fichiers/2019/06/7/1549795460-logo-elorionnetwork.png`)
.setColor(color.elorion)
.addField("Username", username)
.addField("UUID", uuid)
.addField("BuildUHC Elo", resultbu[0].builduhcelo)
.addField("NoDebuff Elo", resultnd[0].nodebuffelo)
.addField("IronBuildUHC Elo", resultibu[0].ironbuilduhcelo)
.addField("Skin", `[Download](https://crafatar.com/skins/${uuid}.png)`)
.setThumbnail(`https://crafatar.com/avatars/${uuid}.png?size=400&overlay=true`)
.setFooter(`Ⓒ Elorion.net 2019. All rights reserved`);
message.channel.send(embed)
})
})
})
I receive this error when the uuid does not exist in the database:
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'builduhcelo' of undefined