Is there a method in firebase, which can check if value exist in DB? Firebase has method .exists(), but according to docs it checks only the keys.
I have the followi
This is how I searched for a url value in Firebasebase database on my project:
const searchFirebase = (url, idx) =>
{
firebase
.app()
.database()
.ref("recipes")
.orderByChild("url")
.equalTo(url)
.once("value", (snapshot) => {
if (snapshot.exists()) {
const userData = snapshot.val();
console.log("exists!", userData);
document.querySelector(`[data-recipe-id="${idx}"]`)
.classList.replace('fav-heart', 'unfav-heart');
} else {
return false;
}
});
}