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
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 typeOrder
will generate the collection nameOrders
. -
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 sameUsers
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.
- RavenDB keeps an internal storage index per collection created.
-
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).
- Each Map Index is built against a single collection (or muliple collections when using a Multi-Map Index.
-
In Revisions
- Documents Revisions can be defined per collection.
-
In Ongoing Tasks
- A RavenDB ETL Task & SQL ETL Task are defined on specified collections.
-
The @hilo Collection
- The ranges of available IDs values returned by HiLo algorithm are per collection name.
Learn more in: The @hilo Collection
- The ranges of available IDs values returned by HiLo algorithm are per collection name.
-
The @empty Collection
- Learn more in: The @empty Collection