---
title: Fields and Key-Values
slug: v4-4/jErrIcHe0QCEH0nmidvln
docTags: 
createdAt: 2023-08-14T16:54:47.181Z
---

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](./#field-property))
- The value that holds the actual data to store. ([Field Values](./#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](docId:67wjvNr54pFMMAE2WRe3S), as follows.

# Field Property

Similar to most document-oriented databases, you can only use `strings` to encode field names in documents.&#x20;

:::hint{type="warning"}
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:
:::

```none
{
    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.&#x20;

- For a `counter`, use only a `number`.&#x20;

- If embedding a `map`, use key-value pairs within the embedded structure.&#x20;

:::hint{type="info"}
For an overview of write behavior by type, see [Data Types](docId\:yxemKH1COm3CSUuMqcnlf).
:::

## Sorting by Field

Sort the results in a specific order by using the Sort method to specify the field for matching and the desired order of the matching query results.

:::hint{type="info"}
By default, queries that do not include a `sort` operation, filter by document ID.&#x20;
:::

## 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 for the children to link related data items as well as organize them in a structure that enhances the efficiency of lookup.

For more information, see [Relationships](docId\:LQGzvVHtqzybx_ALD5b8J).
