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



enter image description here



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();
}
}
});












share|improve this question
























  • 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















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



enter image description here



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();
}
}
});












share|improve this question
























  • 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













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



enter image description here



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();
}
}
});












share|improve this question















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



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)