ユーザーは、私はすべて対応する通知を更新したい彼のプロフィール写真を変更すると、私は通知MongoDBの位置演算子のみ最初に一致したの回避策
{
"notifications": {
"0": {
"id": "1",
"isRead": false,
"user": {
"id": ObjectId("4f7999c5e4b0f2e6b8490e08"),
"firstName": "X",
"lastName": "Y",
"profilePictureUrl": "URL1"
}
},
"1": {
"id": "2",
"user": {
"id": ObjectId("4f7999c5e4b0f2e6b8490e08"),
"firstName": "X",
"lastName": "Y",
"profilePictureUrl": "URL1"
}
}
},
}
のリストをユーザオブジェクトを持っています。私はこのようなモルフィアで何かをしようとしているが、それは最初のエントリだけを更新するようだ。
Query<UserEntity> query = ds.createQuery(UserEntity.class).filter("notifications.user.id",
userProperties.id).field("notifications.user.profilePictureUrl").notEqual(userProperties.profilePictureUrl);
UpdateOperations<UserEntity> op = ds.createUpdateOperations(UserEntity.class).disableValidation()
.set("notifications.$.user.profilePictureUrl", userProperties.profilePictureUrl);
results = update(query, op);
これに対応する回避策はありますか?バックグラウンドでこれをやっていきますので、コストのかかるソリューションもうまくいきます。
私はmorphiaを使用していますが、ここではupdateコマンドの結果はmulti = trueです。 –
これはまだ動作しません –