Ask coding questions

← Back to all posts
Replit database check if key exists

I am trying to do a discord bot, so far so good, but i have only one problem: How can i check if the key i am trying to access exists in the replit database?
if(key exists){
//do sth
somethin like the above.
This is because i need to keep track of user stuff, but i will erase data if i add the set statement everytime the command is ran. This is problematic and bad, so the best solution i have came up with is to check if the database key exists.

Answered by WWEMONSTERMONST [earned 5 cycles]
View Answer

You can use the following code to get all the keys and check if some key exists or not:

Hopefully I was able to help you.