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 a similar solution if you want to check if an email exists in firebase
firebase.app().database().ref("shops").orderByChild("email")
.equalTo(user.email).once("value", snapshot => {
const userData = snapshot.val();
// Check if it is a SHOP.
if (userData) {
console.log("Shop logged in!");
this.setState({
isAdminLoggedIn: false,
isUserLoggedIn: false,
isShopLoggedIn: true,
isNoneLoggedIn: false
});
// Check if it is a USER.
} else {
console.log("User logged in");
this.setState({
isAdminLoggedIn: false,
isUserLoggedIn: true,
isShopLoggedIn: false,
isNoneLoggedIn: false
});
}
});