Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB中的Spring引导动态更新_Mongodb_Spring Boot - Fatal编程技术网

MongoDB中的Spring引导动态更新

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,

是否可以动态更新文档? 否则,例如,如果我将UserProfie作为

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?是的。数据存储来自哪里?