我有一个包含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?
答案 0 :(得分:1)
使用MongoCollection对象上的WithWriteConcern
方法获取一个新的IMongoCollection对象,该对象将使用提供的写入问题进行查询。
var jobInfoDocumentsCareless = jobInfoDocuments.WithWriteConcern(WriteConcern.Unacknowledged);
await jobInfoDocumentsCareless.BulkWriteAsync(operationList, writeOptions);