MongoDB中的Spring引导动态更新
是否可以动态更新文档? 否则,例如,如果我将UserProfie作为MongoDB中的Spring引导动态更新,mongodb,spring-boot,Mongodb,Spring Boot,是否可以动态更新文档? 否则,例如,如果我将UserProfie作为 UserProfile { String name String lastName Object Address String token } 然后,我想为这个文档创建大约3个端点。但如果我能做动态更新,那么我将做一个方法 将更新信息累积到映射中,而不是通过变量传递 Map<String, Object> updateInfo; // Key is db column name,
UserProfile {
String name
String lastName
Object Address
String token
}
然后,我想为这个文档创建大约3个端点。但如果我能做动态更新,那么我将做一个方法 将更新信息累积到
映射中,而不是通过变量传递
Map<String, Object> updateInfo; // Key is db column name, value is updatedValue
Map updateInfo;//键是db列名,值是updatedValue
然后创建动态更新操作:
UpdateOperations<Entity> updateOps = datastore.createUpdateOperations(Entity.class);
updateInfo.entrySet().forEach(e -> updateOps.set(e.getKey(), e.getValue());
UpdateOperations updateOps=datastore.createUpdateOperations(Entity.class);
updateInfo.entrySet().forEach(e->updateOps.set(e.getKey(),e.getValue());
现在,您可以使用这个updateOps
动态更新您的文档。请解释更多。这些方法来自哪里?哪些导入?map是什么意思?您能提供一个具体的例子吗?您正在使用Spring data mongo?是的。数据存储来自哪里?