1
我正在嘗試使用Firestore。Firestore對象更新列表
我有一個集合組包含用戶
public class User {
private String mail;
private String username;
public User() {
}
public User(String mail, String username) {
this.mail = mail;
this.username = username;
}
public String getMail() {
return mail;
}
public String getUsername() {
return username;
}
}
的名單,我想更新這個清單,我已經試過:
List<User> list = new ArrayList<>();
list.add(new User("[email protected]", "foo"));
reference.update("users", list)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "DocumentSnapshot successfully updated!");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error updating document", e);
}
});
}
但我有一個例外:
java.lang.IllegalArgumentException:無效的數據。不支持的類型:my.package.name.models.User
如何使用Firestore更新對象列表?