小编Pra*_*ant的帖子

Checking for a string in firestore always returns true

I am new to android development and firestore. What I am trying to do is compare whether a string exists in the database or not. However, the query always returns true even if I am trying to compare with string that is not present in the database. Here is my code:

public void loadData(View v){
        db.collection("Machines")
                .whereEqualTo("machineId","AYSLE004")
                .get()
                .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                    @Override
                    public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                        //MachineId exists
                        Toast.makeText(MainActivity.this, "Machine Id exists", Toast.LENGTH_LONG).show();
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override …
Run Code Online (Sandbox Code Playgroud)

android google-cloud-firestore

1
推荐指数
1
解决办法
64
查看次数

标签 统计

android ×1

google-cloud-firestore ×1