1

Official Mongo c# 2.0 driver次のコードを使用して、一括更新操作を実行しようとしています:

 var query = 
 Builders<Profile>.Filter.In(p => p.userId, listBounce.Values.ToList()) &
 Builders<Profile>.Filter.In(p => p.ID,  listBounce.Keys.Select(x=> new ObjectId(x)).
 ToList());

 var update = Builders<Profile>.Update.Set(p => p.MailLists[-1].Status, (int)wrongEmailStatusAssetId);

 dbCollection.UpdateManyAsync(query, update).Wait();

しかし、次のエラーが発生しました

{"A write operation resulted in an error.\r\n  
The positional operator did not find the match needed from the query.   
Unexpanded update: p2l.$.status"}

クエリに一致する配列内の各要素のプロパティを更新する必要があります。ドキュメント構造は次のとおりです。

{
    "_id" : ObjectId("55eeb5da965bb036984110b9"),
    "created" : ISODate("2015-09-08T10:17:59.784Z"),
    "userId" : 13929,
    "email" : "go-get@yandex.ru",
    "firstName" : "Skrillex",
    "lastName" : "Skrillex",
    "phoneNumber" : "",
    "isUnsubscribed" : false,
    "isAboveLimit" : false,
    "status" : 0,
    "userAgent" : 9760,
    "isDeleted" : false,
    "p2l" : [ 
        {
            "listId" : 45165,
            "status" : 131,
            "subscriptionDate" : ISODate("2015-09-04T06:24:55.763Z")
        }
    ]
}
4

1 に答える 1