1

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

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

4

2 回答 2

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;;
于 2013-09-17T09:39:38.633 回答
4

仅通过 RavenDB Http Api 获取元数据:

GET http://localhost:8080/indexes/dynamic/MyDocuments/?metadata-only=true

会返回:

{ "Results":[],
  "Includes":[],
  "IsStale":false,
  "IndexTimestamp":"2013-09-16T15:54:58.2465733Z",
  "TotalResults":0,
  "SkippedResults":0,
  "IndexName":"Raven/DocumentsByEntityName",
  "IndexEtag":"01000000-0000-0008-0000-000000000006",
  "ResultEtag":"3B5CA9C6-8934-1999-45C2-66A9769444F0",
  "Highlightings":{},
  "NonAuthoritativeInformation":false,
  "LastQueryTime":"2013-09-16T15:55:00.8397216Z",
  "DurationMilliseconds":102 }

ResultEtag 和 IndexTimestamp 在每次写入时更改

于 2013-09-16T16:30:20.240 回答