So, i've been running a .js app that stores & updates a database on both of a game and a discord bot. I've been using so far this following sql query to add/update data, but i've been looking for a way to only update if ${user.id} does not exist in the databse.
INSERT INTO usermine
(userID, mineCOOLDOWN, coal_mine, silver_mine, gold_mine, diamond_mine)
VALUES( ${user.id}, 1, 1, 1, 1, 1)
ON DUPLICATE KEY UPDATE userID = ${user.id};
I've seen a few other examples in here, but i was not succeful to implement it properly in my project (errored out or did not worked at all)
So more exactly what i need to do is:
check if the ${user.id} is already in the database. If so don't insert anything.
If the ${user.id} is not in the database, it should insert it's {user.id} and have all the other variables set to 1.