问题
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