java - Firestore 不更新嵌入式集合中的值
问题描述
这是父节点
在里面我有客户
我正在尝试更新第一个客户的姓氏。
我有正确的身份证,我检查了很多次。我正在使用JAVA,代码如下:
public void updateClient(ClientDto client) {
if(client.getUserId() == null){
throw new IllegalArgumentException("userId cannot be null when" +
" updating a client");
}
final ClientDto clientById = this.getClientById(client.getClientId(),client.getUserId());
Map<String, Object> data = new HashMap<>();
data.put("name", client.getName());
data.put("lastName", client.getLastName());
data.put("middleName", client.getMiddleName());
data.put("email", client.getEmail());
data.put("phone", client.getPhone());
data.put("lastUpdatedBy", client.getLastUpdatedBy());
data.put("lastUpdatedDate", client.getLastUpdatedDate());
this.fireDao.getDb()
.collection("users").document(client.getUserId())
.collection("clients")
.document(client.getClientId()).update(data);
}
this.fireDao.getDb()
是 firestore 的一个实例,我能够执行所有其他操作。
解决方案
这是有效的:
final ApiFuture<WriteResult> update = this.fireDao.getDb().collection("users").document(client.getUserId())
.collection("clients")
.document(client.getClientId()).update(data);
try {
log.info(format(
"Updating userId %s for customer id %s at time %s",
client.getUserId(),
client.getClientId(),
update.get().getUpdateTime()));
} catch (InterruptedException | ExecutionException e) {
log.error(format(
"Error updating userId %s for customer id %s",
client.getUserId(),
client.getClientId()), e);
}
我认为这条线做到了,但我不确定我为什么需要它:
update.get().getUpdateTime()
推荐阅读
- python - 无法让python exe运行
- python - 如何将 PyTorch 张量转换为 Numpy ndarray
- node.js - Express - 嵌套目录中每个模板文件的路由和渲染引擎
- spring-integration - SimpleMessageListenerContainer - AMQP 接收消息上的 ClassNotFoundException 警告
- reactjs - 我可以在科尔多瓦应用程序中使用苹果支付按钮吗?
- node.js - UnhandledPromiseRejectionWarning:TypeError:无法读取 null 的属性“_id”
- node.js - Ionic Client 网络套接字断开连接
- node.js - 为什么 linting 因“Unexpected token ”而失败。在“import.meta.url”上?
- python - 如何迭代到函数中最右边的叶子
- python - python跳过try语句有问题