英文:
how to compare user input data with my firestore record
问题
我想将用户的输入数据与我的Firestore记录进行比较(这些数据已经存储在我的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 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
得分: 0
直接将文档转换为POJO。Firestore API中有一个名为toObject(Class<T> valueType)
的方法用于解决此问题。
YourClass foo = document.toObject(YourClass.class);
然后,您可以将对象数据与用户输入数据进行比较。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论