Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.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
Java DocumentDb-spring-使用其他字段值更新字段_Java_Spring_Mongodb_Aggregation Framework_Aws Documentdb - Fatal编程技术网

Java DocumentDb-spring-使用其他字段值更新字段

Java DocumentDb-spring-使用其他字段值更新字段,java,spring,mongodb,aggregation-framework,aws-documentdb,Java,Spring,Mongodb,Aggregation Framework,Aws Documentdb,我正在使用来自Spring的DocumentDb,我想对一个字段使用另一个字段的值进行更新 以下查询正在MongoDb控制台中运行: db.mtpProject.update({},[{$set:{“fieldToBeUpdated”:“$myCurrentField”}}])。 如果删除$set之前的[],则该字段不会更新为myCurrentField的值,而是更新为字符串“myCurrentField” 在Java中,我尝试这样执行它: MongoDatabase db=mongoTemp

我正在使用来自Spring的DocumentDb,我想对一个字段使用另一个字段的值进行更新

以下查询正在MongoDb控制台中运行:

db.mtpProject.update({},[{$set:{“fieldToBeUpdated”:“$myCurrentField”}}])。
如果删除$set之前的[],则该字段不会更新为myCurrentField的值,而是更新为字符串“myCurrentField”

在Java中,我尝试这样执行它:

MongoDatabase db=mongoTemplate.getDb();
MongoCollection collection=db.getCollection(“myProject”);
collection.updateMany(new Document(),new Document(“$set”),new
文件(“fieldToBeUpdated”和“$myCurrentField”);
但是因为创建它时没有数组,所以只需将fieldtobeupdate的值设置为“$myCurrentField”

我提到我也尝试过使用$addFields和$out,但是DocumentDb不支持$out

聚合聚合聚合= 聚合( aoc-> 新文件( “$addFields”, 新文档(“fieldToBeUpdated”,“$myCurrentField”), aoc->新文档(“$out”,“myProject”); 聚合(agg,“myProject”,myProject.class);
我希望使用保存在myCurrentField上的值更新字段,而不是使用字段名。

$out现在在Amazon DocumentDB上受支持: