RavenDB 2.x  Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Time for action – exporting documents to a CSV file

You will use the Management Studio to export the Orders database documents to a CSV file.

  1. In the Management Studio, select the Document tab screen.
  2. Click on the Switch between views button and select the Details view mode.
  3. Click on the Export to CSV button to export the database documents to a CSV text file format.
  4. Click on the OK button of the security warning dialog box to confirm the database documents export.
  5. Choose a filename and folder and click on the Save button to save the exported file.

What just happened?

We learned how to export all documents of the Orders database to a CSV file.

In steps 1 and 2, we opened the Management Studio and displayed the Documents screen. Then switched to the Details view mode to show the Export to CSV button.

Note

The Export to CSV button will only appear if you are in the Details view mode.

In steps 3 to 5, we exported all documents of the Orders database to a CSV text file format and saved it on the computer.

RavenDB documents metadata

There are other data stored in RavenDB. These data are called metadata and are usually used to store additional information about entities. The first type of data you might store in addition to the document might be its owner or the one who last modified the document.

Each RavenDB document has metadata properties attached to it, which are being used internally but can be exposed to your code. Here is a list of some properties RavenDB stores as metadata for its documents:

  • Raven-Clr-Type: This metadata is used to record the CLR type which is the type that defines the class object for the data. It is set and used by the JSON serialization/deserialization process in the Client API.
  • Raven-Entity-Name: This metadata records the entity name and determines the name of the RavenDB collection this entity belongs to.
  • Non-Authoritive-Information: This metadata is a boolean value and is used to indicate if the data has been changed. Its value will be set to true if the data received by the client has been modified by an uncommitted transaction.
  • Temp-Index-Score: When querying RavenDB, this value is used to store a mathematical result value calculated by RavenDB to determine how relevant a given document is to a user's query.
  • Raven-Read-Only: This metadata indicates that a document should be considered read-only and RavenDB must not allow the document to be modified.
  • Last-Modified: This metadata value is a time-stamp and indicates the last time the entity has been modified.
  • @etag: Every document in RavenDB has a corresponding ETag (entity tag) stored as a sequential GUID (Globally Unique Identifier) which is a unique sequence. This e-tag is updated by RavenDB every time the document is changed.
  • @id: This metadata value is the entity identifier, as extracted from the entity itself.

More metadata keys are used for storing replication information, concurrency, bookkeeping, and ACL (Access Control List) which is used for securing entities. A consumer application may choose to use those properties for indexing or adding key-value pairs of its own, if required. It is also possible to add your own data to the RavenDB metadata.