请找到附件我的文档的数组结构: Structure of my documents arry
我尝试使用此代码删除此条目,但不幸的是,它不起作用:
Map<String, Object> docData = new HashMap<>();
Map<String, Object> deleteObject = new HashMap<>();
deleteObject.put("chatId", users.get(position).getChatId());
deleteObject.put("contactId", users.get(position).getId());
deleteObject.put("isGroup", users.get(position).isGroup());
deleteObject.put("isRead", users.get(position).isRead());
deleteObject.put("lastMsg", users.get(position).getLastMsg());
deleteObject.put("lastMsgTs", users.get(position).getLastMsgTs());
deleteObject.put("sentBy", users.get(position).getSentBy());
deleteObject.put("active", false);
docData.put("openChats", FieldValue.arrayUnion(deleteObject));
db.collection("Users").document(FirebaseAuth.getInstance().getCurrentUser().getUid())
.set(docData, SetOptions.merge()).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(mActivity, "deleted", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(mActivity, "Unable to delete", Toast.LENGTH_LONG).show();
}
});
我看不到任何错误,也调用了onSuccess。有人知道我不使用数组位置就可以输入一个地图吗