• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.commonType (Common Data Types)
2<!--Kit: ArkData-->
3<!--Subsystem: DistributedDataManager-->
4<!--Owner: @lvcong_oh-->
5<!--Designer: @hollokin; @yuchaozhng-->
6<!--Tester: @lj_liujing; @yippo; @logic42-->
7<!--Adviser: @ge-yafang-->
8
9The **commonType** module defines common data types in data management.
10
11> **NOTE**
12>
13> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
14
15## Modules to Import
16
17```ts
18import { commonType } from '@kit.ArkData';
19```
20
21## AssetStatus
22
23Enumerates the asset statuses. Use the enum name rather than the enum value.
24
25**System capability**: SystemCapability.DistributedDataManager.CommonType
26
27| Name             | Value | Description                        |
28| ----------------- | --- | ---------------------------- |
29| ASSET_NORMAL      | 1   | The asset is in normal status.          |
30| ASSET_INSERT      | 2   | The asset is to be inserted to the cloud.    |
31| ASSET_UPDATE      | 3   | The asset is to be updated to the cloud.    |
32| ASSET_DELETE      | 4   | The asset is to be deleted from the cloud.    |
33| ASSET_ABNORMAL    | 5   | The asset is in abnormal status.          |
34| ASSET_DOWNLOADING | 6   | The asset is being downloaded to a local device.|
35
36## Asset
37
38Represents asset (such as a file, image, or video) information. For details, see the sample code in [Using Distributed Data Objects in Cross-Device Migration](../../database/data-sync-of-distributed-data-object.md#using-distributed-data-objects-in-cross-device-migration).
39
40**System capability**: SystemCapability.DistributedDataManager.CommonType
41
42| Name      | Type                       | Mandatory| Description                              |
43| ---------- | --------------------------- | ---- | ---------------------------------- |
44| name       | string                      | Yes  | Asset name.                      |
45| uri        | string                      | Yes  | Asset URI, which is an absolute path in the system.   |
46| path       | string                      | Yes  | Application sandbox path of the asset.          |
47| createTime | string                      | Yes  | Time when the asset was created.            |
48| modifyTime | string                      | Yes  | Time when the asset was last modified.        |
49| size       | string                      | Yes  | Size of the asset.              |
50| status     | [AssetStatus](#assetstatus) | No  | Asset status. The default value is **ASSET_NORMAL**.|
51
52## Assets
53
54type Assets = Array\<Asset>
55
56Represents an array of [Assets](#asset).
57
58**System capability**: SystemCapability.DistributedDataManager.CommonType
59
60| Type                        | Description                 |
61| ---------------------------- | --------------------- |
62| Array&lt;[Asset](#asset)&gt; | Array of assets.|
63
64## ValueType
65
66type ValueType = null | number | string | boolean | Uint8Array | Asset | Assets
67
68Enumerates the value types, which vary with the parameter function.
69
70**System capability**: SystemCapability.DistributedDataManager.CommonType
71
72| Type      | Description                                   |
73| ---------- | --------------------------------------- |
74| null       | The value is null.                       |
75| number     | The value is a number.                     |
76| string     | The value is a string.                   |
77| boolean    | The value is true or false.                   |
78| Uint8Array | The value is a Uint8 array.          |
79| Asset      | The value is an [Asset](#asset).      |
80| Assets     | The value is an array of [Assets](#assets).|
81
82## ValuesBucket
83
84type ValuesBucket = Record<string, ValueType>
85
86Defines 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 the instance.
87
88**System capability**: SystemCapability.DistributedDataManager.CommonType
89
90| Type| Description                 |
91| ------ | ----------------------- |
92| Record<string, [ValueType](#valuetype)> | Types of the key and value in a KV pair. The key type is string, and the value type is [ValueType](#valuetype).|
93