문제

I want to detect when a collection or index was last modified or written to.

Note: This works on document level, but i need on collection/index level. How to get last write date of a RavenDB document via C#

도움이 되었습니까?

해결책

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;;

다른 팁

getting meta data only via RavenDB Http Api:

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

would return:

{ "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 and IndexTimestamp change on every write

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top