how to compare user input data with my firestore record

心已入冬 提交于 2021-02-11 15:44:00

问题


I want to compare the input data of a user, with my firestore record (data that is already stored in my Firebase.

Task<QuerySnapshot> pLJava = CoRef
            .whereEqualTo("ProgrammingLanguages", "Java")
            .get()
            .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                @Override
                public void onComplete(@NonNull Task<QuerySnapshot> task) {
                    if (task.isSuccessful()) {
                        for (QueryDocumentSnapshot document : task.getResult()) {
                            // document.getData();
                            id = document.getId();
                            if (id.contains("Java")) {

                            }

I already wrote an algorithm to query the input data. Now I want to compare the input data with my Firebase record.

Thanks for all the help in forward!


回答1:


Simply convert the document into a POJO. There's a method toObject(Class<T> valueType) in Firestore API which resolves that.

YourClass foo = document.toObject(YourClass.class);

Then, you may compare the object data with the user's input data.



来源:https://stackoverflow.com/questions/61588740/how-to-compare-user-input-data-with-my-firestore-record

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!