website logo
Legacy DocsPortal
⌘K
Welcome to Ditto
Onboarding
Ditto Basics
SDK Setup Guides
Platform Manual
HTTP API
Kafka Connector
Use Cases
FAQs
Troubleshooting Guide
Support
Docs powered by
Archbee
Platform Manual
Document Model

Fields and Map Key-Values

7min

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 data. (Field Property)
  • The value that holds the actual data to store. (Field Values)

Required and randomly generated and assigned by default upon creation, the first set of fields identify the document. For more information, see Identifier: Default and Custom, as follows.



Field Property

Similar to most document-oriented databases, you can only use strings to encode field names in documents.

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:

Text
|
{
    1: "numeric_fields_are_invalid_here",
    "this_part": "numeric_fields_are_valid_here"
}


Field Values

Values can be encoded using various data types, providing flexibility in representing a wide range of information. However, the supported data types depend on the type of CRDT you are using:

  • For a register, use any type: such as strings, numbers, objects, or even binary data.
  • For a counter, use only a number.
  • If embedding a map, use key-value pairs within the embedded structure.

Sorting by Field

Sort results by specific order by using the sort method to specify the field to match and the order want matching query results to be arranged.

By default, queries that do not include a sort operation, filter by document ID.



Limiting by Field

Restrict the number of results returned by your query by using the limit method to specify the number of results you want to return.



Map Key-Value Pairs

Establishes a parent-child hierarchy between data elements where the key serves as the parent and the associated values the children to link related data items as well as organize them in a structure that enhances efficiency of lookup.

Updated 27 Sep 2023
Did this page help you?
PREVIOUS
Document Model
NEXT
Identifier: Default and Custom
Docs powered by
Archbee
TABLE OF CONTENTS
Field Property
Field Values
Sorting by Field
Limiting by Field
Map Key-Value Pairs
Docs powered by
Archbee