Firestore: how to perform a query with inequality / not equals

后端 未结 7 1673
南笙
南笙 2020-11-22 05:05

I want select from Firestore collection just articles written NOT by me.
Is it really so hard?

Every article has field "owner_uid".

相关标签:
7条回答
  • 2020-11-22 06:00

    For android it should be easy implement with Task Api. Newbie example:

        FirebaseFirestore db = FirebaseFirestore.getInstance();
        Query lessQuery = db.collection("users").whereLessThan("uid", currentUid);
        Query greaterQuery = db.collection("users").whereGreaterThan("uid", currentUid);
        Task lessQuery Task = firstQuery.get();
        Task greaterQuery = secondQuery.get();
    
        Task combinedTask = Tasks.whenAllSuccess(lessQuery , greaterQuery)
                                 .addOnSuccessListener(new OnSuccessListener<List<Object>>() {
            @Override
            public void onSuccess(List<Object> list) {
    
                //This is the list of "users" collection without user with currentUid
            }
        });
    

    Also, with this you can combine any set of queries.

    For web there is rxfire

    0 讨论(0)
提交回复
热议问题