如何修改写入关注度?

时间:2016-03-29 14:00:19

标签: c# mongodb

我有一个包含100,000,000个文档的集合,其中我每分钟都在执行更新。像这样:

var writeOptions = new BulkWriteOptions { IsOrdered = false };

// Applying several operations within the one request.
operationList.Add(new UpdateOneModel<JobInfoRecord>(Builders<JobInfoRecord>.Filter.Eq("_id", document.JobId),
                                 Builders<JobInfoRecord>.Update.Set("JobInfo", newInfo)));

await jobInfoDocuments.BulkWriteAsync(operationList, writeOptions);

如何将写入关注度从1(默认值)更改为0?

1 个答案:

答案 0 :(得分:1)

使用MongoCollection对象上的WithWriteConcern方法获取一个新的IMongoCollection对象,该对象将使用提供的写入问题进行查询。

 var jobInfoDocumentsCareless = jobInfoDocuments.WithWriteConcern(WriteConcern.Unacknowledged);
 await jobInfoDocumentsCareless.BulkWriteAsync(operationList, writeOptions);