When Marten generates a table for document storage it now adds several metadata columns that further describe the document:
mt_last_modified
- a timestamp of the last time the document was modifiedmt_dotnet_type
- TheFullName
property of the actual .Net type persisted. This is strictly for information and is not used by Marten itself.mt_version
- A sequential Guid designating the revision of the document. Marten uses this column in its optimistic concurrency checksmt_doc_type
- document name (document hierarchies only)mt_deleted
- a boolean flag representing deleted state (soft deletes only)mt_deleted_at
- a timestamp of the time the document was deleted (soft deletes only)
Finding the Metadata for a Document
You can find the metadata values for a given document object with the following mechanism
on IDocumentStore.Advanced
:
[Fact]
public void hit_returns_values()
{
var shop = new CoffeeShop();
using (var session = theStore.OpenSession())
{
session.Store(shop);
session.SaveChanges();
}
var metadata = theStore.Tenancy.Default.MetadataFor(shop);
SpecificationExtensions.ShouldNotBeNull(metadata);
metadata.CurrentVersion.ShouldNotBe(Guid.Empty);
metadata.LastModified.ShouldNotBe(default(DateTime));
metadata.DotNetType.ShouldBe(typeof(CoffeeShop).FullName);
SpecificationExtensions.ShouldBeNull(metadata.DocumentType);
metadata.Deleted.ShouldBeFalse();
SpecificationExtensions.ShouldBeNull(metadata.DeletedAt);
}