Platform Manual
Document Model
data is stored in ditto as a schema flexible unit referred to as a document the data that documents contain can be exposed using a variety of data formats; however, json format is most common a set of documents grouped together is referred to as a collection a collection can be thought of like a table in a relational database table — but with greater flexibility in terms of the data it can hold — and the documents in a collection like table rows the following table provides a basic definition of a document; the fundamental unit of data storage in ditto for more information, see ditto basics > docid\ p6opubbna hc2dcjwshs structure a ditto document is a group of key value pairs content the values in a document can include various scalar types like strings , numbers , booleans , arrays , and more documents can contain nested map data types, allowing them to represent complex hierarchical structures identification each document has a unique id field that acts at a primary key the id field is automatically added by ditto if not provided during document creation flexibility ditto is schema less, meaning that documents within the same collection do not need to have the same set of fields or structure this flexibility allows for the evolution of data models over time without requiring changes to existing data fields a document consists of sets of fields that self describe the data it encodes each set signifies a single pair of two associated elements the name identifying the field the value that holds the data ditto document { id "123", field1 "abc", field2 1, field3 { sub field1 "xyz", sub field2 2 } } similar to most document oriented databases, you can only use strings to encode field names in documents for complete naming rules, see docid\ e3uqqeqvzvotjls2xfdfl > docid\ obsl86zmxluex0uhjfcph > docid\ obsl86zmxluex0uhjfcph if you attempt to insert a type other than a string for a field property, as demonstrated in the following snippet, you will receive an error message { 1 "numeric fields are invalid here", "this part" "numeric fields are valid here" } nested fields in the following structure, the location field property is logically grouped with details about the car, such as its make , year , and color it contains nested fields also referred to as subfields , representing both the coordinates and the address where the car is located values values can be encoded using various data types, including scalar type, providing flexibility in representing a wide range of information data types provide flexibility in representing a range of information and consist of a merge behavior plus a scalar value data types include register , map , and attachment for more information and how to instructions, see platform manual > docid\ vofl0gukxq8ajsmmw7sgz