FAQ: What is a Collection


  • A collection in RavenDB is a set of documents tagged with the same @collection metadata property.
    Every document belongs to exactly one collection.

  • Being a schemaless database, there is no requirement that documents in the same collection will share the same structure,
    although typically, a collection holds similarly structured documents based on the entity type of the document.

  • The collection is just a virtual concept.
    There is no influence on how or where documents within the same collection are physically stored.

  • Collections are used throughout many RavenDB features, such as defining indexes, setting revisions, and much more.

  • In this page:

  • For more information see Documents and Collections

Figure 1. What is a Collection

A document in 'Users' collection


Collection Name Generation

When storing an entity from the client:

  • The document collection metadata is generated based on the stored entity object type.

  • By default, the client pluralizes the collection name based on the type name.
    e.g. storing an entity of type Order will generate the collection name Orders.

  • The function that is responsible for tagging the documents can be overridden.
    See: Global Identifier Generation Conventions.


When creating a new document through the Studio:

  • The collection metadata is generated based on the document ID prefix.
    e.g Documents that are created with the following IDs: users|23 / users/45 / users/17
    will all belong to the same Users collection.

  • For more information see Documents and Collections

Collection Usages

  • A Collection Query

    • RavenDB keeps an internal storage index per collection created.
      This internal index is used to query the database and retrieve only documents from a specified collection.
  • In Indexing

    • Each Map Index is built against a single collection (or muliple collections when using a Multi-Map Index.
      During the indexing process, the index function iterates only over the documents that belong to the specified collection(s).
  • In Revisions

    • Documents Revisions can be defined per collection.
  • In Ongoing Tasks

  • The @hilo Collection

  • The @empty Collection