• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.ValuesBucket (Data Set)
2
3**ValuesBucket** is a dataset in the form of key-value (KV) pairs that can be inserted in the database.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> The APIs of this module can be used only in the stage model.
10
11
12## Modules to Import
13
14```ts
15import { ValueType, ValuesBucket } from '@kit.ArkData';
16```
17
18## ValueType
19
20type ValueType = number | string | boolean
21
22Defines the value types allowed in a **ValuesBucket** instance.
23
24**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
25
26**Atomic service API**: This API can be used in atomic services since API version 20.
27
28| Type   | Description                |
29| ------- | -------------------- |
30| number  | The value is a number.  |
31| string  | The value is a string.|
32| boolean | The value is **true** or **false**.|
33
34## ValuesBucket
35
36type ValuesBucket = Record<string, ValueType | Uint8Array | null>
37
38Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for it.
39
40**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
41
42| Type         | Description                                     |
43| ------------- | --------------------------------------------- |
44| Record<string, [ValueType](#valuetype) \| Uint8Array \| null> | Types of the key and value in a KV pair. The key type is string, and the value type can be [ValueType](#valuetype), Uint8Array, or null.|
45