如何获取RavenDB集合/索引的最后写入日期

Mar*_*ger 1 ravendb ravendb-http

我想检测集合或索引的最后修改或写入时间。

注意:这在文档级别有效,但是我需要在集合/索引级别。如何通过C#获取RavenDB文档的最后写入日期

Mar*_*ger 5

RavenQueryStatistics stats;

using(var session = _documentStore.OpenSession()) {
    session.Query<MyDocument>()
        .Statistics(out stats)
        .Take(0) // don't load any documents as we need only the stats
        .ToArray(); // this is needed to trigger server side query execution
}

DateTime indexTimestamp = stats.IndexTimestamp;
string indexEtag = stats.IndexEtag;;
Run Code Online (Sandbox Code Playgroud)