Skip to main content

Exists

Checks if a key exists in the database.

  • Parameters:
    • key: The key to check.
  • Returns:
    • The result of the operation, includes a boolean indicating whether the operation was successful or an error if the operation failed.
if (db.exists("user:12345").success) {
console.log("User exists");
} else {
console.log("User does not exist");
}
info

The exists method is faster than get because it uses a simpler SQL query. Use exists when you only need to check if a key is present, as it can boost performance in speed-sensitive situations.