Skip to main content

MongoDB

MongoDB is a primary database. It stores everything which does not fit into the graph: one document per element, in a collection per type, with the objects, lists, vectors, geo values and long strings of the element.

What it stores

ValuesStored as
object, listembedded documents and arrays, always
vectorarray of numbers, by default
geo typesGeoJSON objects, by default
string of more than 1024 charactersstring, by default
scalar typesnative values, if placed here

Properties which are stored in MongoDB, and all nested properties, are indexed here: exact creates an ascending index, fulltext adds the property to the text index of the collection and geo creates a 2dsphere index, see nested properties. A migration creates the indices and adds a $jsonSchema validator to the collection, a second line of defense behind the validation of the API.

Limits

  • 16 MB per document: a document can not be larger than 16 MB. All properties of an element which are stored in MongoDB share this limit, writes which exceed it fail. Large data belongs into a file.
  • 100 levels of nesting: documents can be nested at most 100 levels deep. The API does not limit the nesting of objects, so this is the effective limit.

Migrations

Creating the collection and setting the validator are also done when a schema is saved and after a backup load (the steps create-collection and update-validator). Building indices can take long on big collections and stays migration work, as does removing a validator; errors are logged and do not fail the save. A migration adds the $jsonSchema validator for the properties which are stored in MongoDB (object, list, vector, geo values and long strings) and everything inside objects and lists (dates there as RFC 3339 strings), and creates the indices of these properties, including nested ones. The validator is only applied to documents which are valid already, and null is always allowed. Validators which were not created by schemas are never touched.

See also