我正在使用此代码块在集合中查找文档。 我可以从游标中获取文件计数吗?
还是有一种方法可以通过给findoptions来仅获取文档数?
using (var cursor = await collection.FindAsync(filterExpression, new FindOptions<BsonDocument, BsonDocument>
{
Projection = projectionDef,
Skip = findOptions.Skip,
Limit = findOptions.Limit,
Sort = sortExpression
}, cancellationToken).ConfigureAwait(false))
{
while (await cursor.MoveNextAsync().ConfigureAwait(false))
{
foreach (var document in cursor.Current)
{
var docObject = BsonSerializer.Deserialize<object>(document);
var x = JObject.FromObject(docObject);
result.Add(x);
}
}
}
我正在使用mongo db driver 2.4.4