Firestore Query with clause WhereEqualTo return always empty result
up vote
0
down vote
favorite
I am trying to get one document in my collection with android Firebase Cloud Firestore using clause WhereEqualTo on a one field, but i don't know why i get sometime empty result whith the same data in my database.
Sometime the result is empty. When i remove the clause whereEqualTo, i get all the collection.
here is my request
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
here is my User class
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
and here is my data
and i use it like this
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
android firebase google-cloud-firestore
add a comment |
up vote
0
down vote
favorite
I am trying to get one document in my collection with android Firebase Cloud Firestore using clause WhereEqualTo on a one field, but i don't know why i get sometime empty result whith the same data in my database.
Sometime the result is empty. When i remove the clause whereEqualTo, i get all the collection.
here is my request
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
here is my User class
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
and here is my data
and i use it like this
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
android firebase google-cloud-firestore
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
WHat doesUserHelper.getUsersCollection()
return? Please responde with @.
– Alex Mamo
Nov 12 at 18:40
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to get one document in my collection with android Firebase Cloud Firestore using clause WhereEqualTo on a one field, but i don't know why i get sometime empty result whith the same data in my database.
Sometime the result is empty. When i remove the clause whereEqualTo, i get all the collection.
here is my request
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
here is my User class
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
and here is my data
and i use it like this
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
android firebase google-cloud-firestore
I am trying to get one document in my collection with android Firebase Cloud Firestore using clause WhereEqualTo on a one field, but i don't know why i get sometime empty result whith the same data in my database.
Sometime the result is empty. When i remove the clause whereEqualTo, i get all the collection.
here is my request
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
here is my User class
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
and here is my data
and i use it like this
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
public static Task<QuerySnapshot> getUserByEmail() {
String email = "mireille@sombux.com";
return UserHelper.getUsersCollection()
.whereEqualTo("email", email)
.get();
}
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
public abstract class User {
private long id;
private String email;
private Date lastLogin;
private Date birthday;
private String country;
private String codcountry;
private String formation;
private String drink;
private String about;
public User() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCodcountry() {
return codcountry;
}
public void setCodcountry(String codcountry) {
this.codcountry = codcountry;
}
public String getFormation() {
return formation;
}
public void setFormation(String formation) {
this.formation = formation;
}
public String getDrink() {
return drink;
}
public void setDrink(String drink) {
this.drink = drink;
}
public String getAbout() {
return about;
}
public void setAbout(String about) {
this.about = about;
}
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
UserHelper.getUserByEmail().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
final User remoteUser = document.toObject(User.class);
if (remoteUser != null) {
Toast.makeText(context, "Find", Toast.LENGTH_SHORT).show();
// do something
}
return;
}
Toast.makeText(context, "Not find", Toast.LENGTH_SHORT).show();
}
}
});
android firebase google-cloud-firestore
android firebase google-cloud-firestore
edited Nov 11 at 4:36
asked Nov 10 at 16:57
Oumar
214
214
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
WHat doesUserHelper.getUsersCollection()
return? Please responde with @.
– Alex Mamo
Nov 12 at 18:40
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35
add a comment |
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
WHat doesUserHelper.getUsersCollection()
return? Please responde with @.
– Alex Mamo
Nov 12 at 18:40
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
WHat does
UserHelper.getUsersCollection()
return? Please responde with @.– Alex Mamo
Nov 12 at 18:40
WHat does
UserHelper.getUsersCollection()
return? Please responde with @.– Alex Mamo
Nov 12 at 18:40
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241249%2ffirestore-query-with-clause-whereequalto-return-always-empty-result%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where are the onSuccess and onFailure listeners?
– Hocine B
Nov 10 at 17:07
I use this onCompletListener like a new update
– Oumar
Nov 11 at 4:31
WHat does
UserHelper.getUsersCollection()
return? Please responde with @.– Alex Mamo
Nov 12 at 18:40
it return FirebaseFirestore.getInstance().collection("users");
– Oumar
Nov 15 at 17:35