Damian Hickey

Mostly software and .NET related. Mostly.

Getting a document's metadata in RavenDB via client API without loading the document

In an upcoming build of RavenDB (current is 588) you will be able get document's metadata wiithout having to loading it:

JsonDocumentMetadata docMetaData = store.DatabaseCommands.Head(string key);
...where docMetaData will be null when the document does not exist.

If all you want to do is check if it exists, one can use an extension method (guards omitted for berevity):

public static cass IDocumentStoreExtensions
	public static bool Exists(this IDocumentStore documentStore, string key)
		return documentStore.DatabaseCommands.Head(key) != null;