如何将用户输入数据与我的Firestore记录进行比较 [英] how to compare user input data with my firestore record

查看:72
本文介绍了如何将用户输入数据与我的Firestore记录进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将用户的输入数据与我的Firestore记录(已经存储在Firebase中的数据进行比较.

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")) {

                            }

我已经写了一种算法来查询输入数据.现在,我想将输入数据与Firebase记录进行比较.

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!

推荐答案

只需将文档转换为POJO.Firestore API中有一个方法 toObject(Class< T> valueType)可以解决该问题.

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.

这篇关于如何将用户输入数据与我的Firestore记录进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆