• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Enums
2
3> **NOTE**
4>
5> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6
7## SecurityLevel
8
9Enumerates the KV store security levels. Use the enum name rather than the enum value. You cannot change the security level of an RDB store from a higher level to a lower one.
10
11> **NOTE**
12>
13> To perform data sync operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see [Access Control Mechanism in Cross-Device Sync](../../database/sync-app-data-across-devices-overview.md#access-control-mechanism-in-cross-device-sync).
14
15**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
16
17| Name| Value  | Description                                                        |
18| ---- | ---- | ------------------------------------------------------------ |
19| S1   | 1    | The RDB store security level is low. If data leakage occurs, minor impact will be caused on the database. An example would be a graph store containing non-sensitive system data such as wallpapers.|
20| S2   | 2    | The RDB store security level is medium. If data leakage occurs, moderate impact will be caused on the database. An example would be a graph store containing audio and video data created by users or call logs.|
21| S3   | 3    | The RDB store security level is high. If data leakage occurs, major impact will be caused on the database. An example would be a graph store containing user fitness, health, and location data.|
22| S4   | 4    | The RDB store security level is critical. If data leakage occurs, severe impact will be caused on the database. An example would be a graph store containing authentication credentials and financial data.|
23
24## EncryptionAlgo<sup>14+</sup>
25
26Enumerates the database encryption algorithms. Use the enum name rather than the enum value.
27
28**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
29
30| Name| Value  | Description|
31| ---- | ---- | ---- |
32| AES_256_GCM |  0    | AES_256_GCM.    |
33| AES_256_CBC |  1    | AES_256_CBC.    |
34
35## HmacAlgo<sup>14+</sup>
36
37Enumerates the HMAC algorithms for the database. Use the enum name rather than the enum value.
38
39**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
40
41| Name| Value  | Description|
42| ---- | ---- | ---- |
43| SHA1 |  0    | HMAC_SHA1.    |
44| SHA256 |  1    | HMAC_SHA256.    |
45| SHA512 |  2    | HMAC_SHA512.   |
46
47## KdfAlgo<sup>14+</sup>
48
49Enumerates the PBKDF2 algorithms for the database. Use the enum name rather than the enum value.
50
51**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
52
53| Name| Value  | Description|
54| ---- | ---- | ---- |
55| KDF_SHA1 |  0    | PBKDF2_HMAC_SHA1.    |
56| KDF_SHA256 |  1    | PBKDF2_HMAC_SHA256.    |
57| KDF_SHA512 |  2    | PBKDF2_HMAC_SHA512.    |
58
59## Tokenizer<sup>17+</sup>
60
61Enumerates tokenizers that can be used for FTS. Use the enum name rather than the enum value.
62
63**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
64
65| Name                             | Value  | Description            |
66| ------------------------------- | --- | -------------- |
67| NONE_TOKENIZER     | 0  | No tokenizer is used.     |
68| ICU_TOKENIZER | 1 | The ICU tokenizer is used, which supports Chinese and multiple languages. If the ICU tokenizer is used, you can set the language to use, for example, **zh_CN** for Chinese and **tr_TR** for Turkish. For details about the supported languages, see [ICU tokenizer](https://gitee.com/openharmony/third_party_icu/blob/master/icu4c/source/data/lang/en.txt). For details about the language abbreviations, see [locales](https://gitee.com/openharmony/third_party_icu/tree/master/icu4c/source/data/locales).|
69| CUSTOM_TOKENIZER<sup>18+</sup> | 2 | A custom tokenizer is used. Chinese (simplified and traditional), English, and Arabic numerals are supported. Compared with **ICU_TOKENIZER**, **CUSTOM_TOKENIZER** has advantages in tokenization accuracy and resident memory usage. The self-developed tokenizer supports two modes: default tokenization mode and short word tokenization mode (short_words). You can use the cut_mode parameter to specify the mode. If no mode is specified, the default mode is used.|
70
71The table creation statement varies with the tokenizer in use.
72
73**Example**:
74
75The following is an example of the table creation statement when **ICU_TOKENIZER** is used:
76
77```ts
78import { relationalStore } from '@kit.ArkData'; // Import the relationalStore module.
79import { UIAbility } from '@kit.AbilityKit';
80import { BusinessError } from '@kit.BasicServicesKit';
81import { window } from '@kit.ArkUI';
82
83// In this example, Ability is used to obtain an RdbStore instance in the stage model. You can use other implementations as required.
84class EntryAbility extends UIAbility {
85  async onWindowStageCreate(windowStage: window.WindowStage) {
86    let store: relationalStore.RdbStore | undefined = undefined;
87    const STORE_CONFIG: relationalStore.StoreConfig = {
88      name: "MyStore.db",
89      securityLevel: relationalStore.SecurityLevel.S3,
90      tokenizer: relationalStore.Tokenizer.ICU_TOKENIZER
91    };
92    store = await relationalStore.getRdbStore(this.context, STORE_CONFIG);
93
94    const SQL_CREATE_TABLE = "CREATE VIRTUAL TABLE example USING fts4(name, content, tokenize=icu zh_CN)";
95    if (store != undefined) {
96      (store as relationalStore.RdbStore).executeSql(SQL_CREATE_TABLE, (err) => {
97        if (err) {
98          console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
99          return;
100        }
101        console.info('create virtual table done.');
102      });
103    }
104  }
105}
106```
107
108The following is an example of the table creation statement when **CUSTOM_TOKENIZER** is used:
109
110```ts
111import { relationalStore } from '@kit.ArkData'; // Import the relationalStore module.
112import { UIAbility } from '@kit.AbilityKit';
113import { BusinessError } from '@kit.BasicServicesKit';
114import { window } from '@kit.ArkUI';
115
116// In this example, Ability is used to obtain an RdbStore instance in the stage model. You can use other implementations as required.
117class EntryAbility extends UIAbility {
118  async onWindowStageCreate(windowStage: window.WindowStage) {
119    let store: relationalStore.RdbStore | undefined = undefined;
120    const STORE_CONFIG: relationalStore.StoreConfig = {
121      name: "MyStore.db",
122      securityLevel: relationalStore.SecurityLevel.S3,
123      tokenizer: relationalStore.Tokenizer.CUSTOM_TOKENIZER
124    };
125    store = await relationalStore.getRdbStore(this.context, STORE_CONFIG);
126
127    const SQL_CREATE_TABLE = "CREATE VIRTUAL TABLE example USING fts5(name, content, tokenize='customtokenizer')";
128    if (store != undefined) {
129      (store as relationalStore.RdbStore).executeSql(SQL_CREATE_TABLE, (err) => {
130        if (err) {
131          console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
132          return;
133        }
134        console.info('create virtual table done.');
135      });
136    }
137  }
138}
139```
140
141The following is an example of the table creation statement when **CUSTOM_TOKENIZER** is used:
142
143```ts
144import { relationalStore } from '@kit.ArkData'; // Import the relationalStore module.
145import { UIAbility } from '@kit.AbilityKit';
146import { window } from '@kit.ArkUI';
147
148export default class EntryAbility extends UIAbility {
149  async onWindowStageCreate(windowStage: window.WindowStage) {
150    console.info('custom tokenizer example: window stage create begin.');
151    let store: relationalStore.RdbStore | undefined = undefined;
152    const storeConfig: relationalStore.StoreConfig = {
153      name: "MyStore.db",
154      securityLevel: relationalStore.SecurityLevel.S3
155    };
156    let customType = relationalStore.Tokenizer.CUSTOM_TOKENIZER;
157    let customTypeSupported = relationalStore.isTokenizerSupported(customType);
158    if (customTypeSupported) {
159      storeConfig.tokenizer = customType;
160    } else {
161      console.info('custom tokenizer example: not support custom tokenizer.');
162      return;
163    }
164    store = await relationalStore.getRdbStore(this.context, storeConfig);
165
166    const sqlCreateTable =
167      "CREATE VIRTUAL TABLE example USING fts5(name, content, tokenize='customtokenizer cut_mode short_words')";
168    if (store != undefined) {
169      (store as relationalStore.RdbStore).executeSql(sqlCreateTable, (err) => {
170        if (err) {
171          console.error(`custom tokenizer example: ExecuteSql failed, code is ${err.code},message is ${err.message}`);
172          return;
173        }
174        console.info('custom tokenizer example: create virtual table done.');
175      });
176    }
177  }
178}
179```
180
181## AssetStatus<sup>10+</sup>
182
183Enumerates the asset statuses. Use the enum name rather than the enum value.
184
185**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
186
187| Name                             | Value  | Description            |
188| ------------------------------- | --- | -------------- |
189| ASSET_NORMAL     | 1  | The asset is in normal status.     |
190| ASSET_INSERT | 2 | The asset is to be inserted to the cloud.|
191| ASSET_UPDATE | 3 | The asset is to be updated to the cloud.|
192| ASSET_DELETE | 4 | The asset is to be deleted from the cloud.|
193| ASSET_ABNORMAL    | 5   | The asset is in abnormal status.     |
194| ASSET_DOWNLOADING | 6   | The asset is being downloaded to a local device.|
195
196## SyncMode
197
198Defines the database synchronization mode. Use the enum name rather than the enum value.
199
200| Name          | Value  | Description                              |
201| -------------- | ---- | ---------------------------------- |
202| SYNC_MODE_PUSH                       | 0   | Data is pushed from a local device to a remote device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
203| SYNC_MODE_PULL                       | 1   | Data is pulled from a remote device to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
204| SYNC_MODE_TIME_FIRST<sup>10+</sup>   | 4   | Synchronize with the data with the latest modification time.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
205| SYNC_MODE_NATIVE_FIRST<sup>10+</sup> | 5   | Synchronize data from a local device to the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
206| SYNC_MODE_CLOUD_FIRST<sup>10+</sup>  | 6   | Synchronize data from the cloud to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
207
208## Origin<sup>11+</sup>
209
210Enumerates the data sources. Use the enum name rather than the enum value.
211
212**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
213
214| Name          | Value  | Description                              |
215| -------------- | ---- | ---------------------------------- |
216| LOCAL       | 0   | Local data.     |
217| CLOUD       | 1   | Cloud data.    |
218| REMOTE      | 2   | Remote device data.|
219
220## Field<sup>11+</sup>
221
222Enumerates predicates used as query conditions. Use the enum name rather than the enum value.
223
224**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
225
226| Name          | Value  | Description                              |
227| -------------- | ---- | ---------------------------------- |
228| CURSOR_FIELD        | '#_cursor'     | Field name used for cursor-based search.|
229| ORIGIN_FIELD        | '#_origin'     | Field name used to specify the data source in cursor-based search.   |
230| DELETED_FLAG_FIELD  | '#_deleted_flag' | Whether the dirty data (data deleted from the cloud) is cleared from the local device. It fills in the result set returned upon the cursor-based search.<br>The value **true** means the dirty data is cleared; the value **false** means the opposite.|
231| DATA_STATUS_FIELD<sup>12+</sup>   | '#_data_status' | Data status in the cursor-based search result set. The value **0** indicates normal data status; **1** indicates that data is retained after the account is logged out; **2** indicates that data is deleted from the cloud; **3** indicates that data is deleted after the account is logged out.|
232| OWNER_FIELD  | '#_cloud_owner' | Party who shares the data. It fills in the result set returned when the owner of the shared data is searched.|
233| PRIVILEGE_FIELD  | '#_cloud_privilege' | Operation permission on the shared data. It fills in the result set returned when the permission on the shared data is searched.|
234| SHARING_RESOURCE_FIELD   | '#_sharing_resource_field' | Resource shared. It fills in the result set returned when the shared resource is searched.|
235
236## SubscribeType
237
238Enumerates the subscription types. Use the enum name rather than the enum value.
239
240| Name                 | Value  | Description              |
241| --------------------- | ---- | ------------------ |
242| SUBSCRIBE_TYPE_REMOTE | 0    | Subscribe to remote data changes.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
243| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1  | Subscribe to cloud data changes.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
244| SUBSCRIBE_TYPE_CLOUD_DETAILS<sup>10+</sup> | 2  | Subscribe to details of the cloud data change.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
245| SUBSCRIBE_TYPE_LOCAL_DETAILS<sup>12+</sup> | 3  | Subscribe to details of the local data change.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
246
247## RebuildType<sup>12+</sup>
248
249Enumerates the RDB store rebuild types. Use the enum name rather than the enum value.
250
251**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
252
253| Name   | Value  | Description                                                                                                            |
254| ------- | ---- |----------------------------------------------------------------------------------------------------------------|
255| NONE    | 0    | The RDB store is not rebuilt.                                                                                                   |
256| REBUILT | 1    | The RDB store is rebuilt and creates an empty database. You need to create tables and restore data.                                                                            |
257| REPAIRED | 2    | The database is repaired and the undamaged data is restored. Currently, only the [vector store](arkts-apis-data-relationalStore-i.md#storeconfig) supports this capability.|
258
259## ChangeType<sup>10+</sup>
260
261Enumerates data change types. Use the enum name rather than the enum value.
262
263**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
264
265| Name                        | Value  | Description                        |
266| -------------------------- | --- | -------------------------- |
267| DATA_CHANGE  | 0   | Data change.  |
268| ASSET_CHANGE | 1   | Asset change.|
269
270## DistributedType<sup>10+</sup>
271
272Enumerates the distributed database table types. Use the enum name rather than the enum value.
273
274| Name               | Value  | Description                                                                                                |
275| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
276| DISTRIBUTED_DEVICE | 0  | Distributed database table synced between devices.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core              |
277| DISTRIBUTED_CLOUD  | 1   | Distributed database table synced between a device and the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
278
279## ConflictResolution<sup>10+</sup>
280
281Enumerates the resolutions used when a conflict occurs during data insertion or modification. Use the enum name rather than the enum value.
282
283**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
284
285| Name                | Value  | Description                                                        |
286| -------------------- | ---- | ------------------------------------------------------------ |
287| ON_CONFLICT_NONE | 0 | No operation is performed.|
288| ON_CONFLICT_ROLLBACK | 1    | Abort the SQL statement and roll back the current transaction.               |
289| ON_CONFLICT_ABORT    | 2    | Abort the current SQL statement and revert any changes made by the current SQL statement. However, the changes made by the previous SQL statement in the same transaction are retained and the transaction remains active.|
290| ON_CONFLICT_FAIL     | 3    | Abort the current SQL statement. The **FAIL** resolution does not revert previous changes made by the failed SQL statement or end the transaction.|
291| ON_CONFLICT_IGNORE   | 4    | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
292| ON_CONFLICT_REPLACE  | 5    | Delete pre-existing rows that cause the constraint violation before inserting or updating the current row, and continue to execute the command normally.|
293
294## Progress<sup>10+</sup>
295
296Enumerates the stages in the device-cloud sync progress. Use the enum name rather than the enum value.
297
298**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
299
300| Name            | Value  | Description                    |
301| ---------------- | ---- | ------------------------ |
302| SYNC_BEGIN       | 0    | The device-cloud sync starts.  |
303| SYNC_IN_PROGRESS | 1    | The device-cloud sync is in progress.|
304| SYNC_FINISH      | 2    | The device-cloud sync is finished.|
305
306## ProgressCode<sup>10+</sup>
307
308Enumerates the device-cloud sync states. Use the enum name rather than the enum value.
309
310**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
311
312| Name                 | Value  | Description                                                        |
313| --------------------- | ---- | ------------------------------------------------------------ |
314| SUCCESS               | 0    | The device-cloud sync is successful.                                      |
315| UNKNOWN_ERROR         | 1    | An unknown error occurs during the device-cloud sync.                              |
316| NETWORK_ERROR         | 2    | A network error occurs during the device-cloud sync.                              |
317| CLOUD_DISABLED        | 3    | The cloud is unavailable.                                            |
318| LOCKED_BY_OTHERS      | 4    | The device-cloud sync of another device is being performed.<br>The sync of the local device can be performed only when the cloud resources are available.|
319| RECORD_LIMIT_EXCEEDED | 5    | The number of records or size of the data to be synced exceeds the maximum. The maximum value is configured on the cloud.|
320| NO_SPACE_FOR_ASSET    | 6    | The remaining cloud space is less than the size of the data to be synced.                    |
321| BLOCKED_BY_NETWORK_STRATEGY<sup>12+</sup>    | 7    | The device-cloud sync is blocked due to the network strategy.                    |
322
323## TransactionType<sup>14+</sup>
324
325Enumerates the types of transaction objects that can be created. Use the enum name rather than the enum value.
326
327**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
328
329| Name            | Value  | Description                    |
330| ---------------- | ---- | ------------------------ |
331| DEFERRED       | 0    | Deferred transaction object. When a deferred transaction object is created, automatic commit is disabled and no transaction will start. A read or write transaction starts only when the first read or write operation is performed.  |
332| IMMEDIATE | 1    | Immediate transaction object. When an immediate transaction object is created, a write transaction starts. If there is any uncommitted write transaction, the transaction object cannot be created and error 14800024 is returned.|
333| EXCLUSIVE      | 2    | Exclusive transaction object. In WAL mode, the exclusive transaction object is the same as the immediate transaction object. In other log modes, this type of transaction can prevent the database from being read by other connections during the transaction.|
334
335## ColumnType<sup>18+</sup>
336
337Enumerates the types of the column data. Use the enum name rather than the enum value.
338
339**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
340
341| Name         | Value  | Description                                                        |
342| ------------- | ---- | ------------------------------------------------------------ |
343| NULL          | 0    | NULL.                                      |
344| INTEGER       | 1    | 64-bit integer. <br>The column can hold 8-bit (including Boolean values), 16-bit, 32-bit, and 64-bit integers. If the 64-bit integer is greater than 2^53 or less than -2^53, use [getString](arkts-apis-data-relationalStore-ResultSet.md#getstring) to convert the 64-bit integer to a string.|
345| REAL          | 2    | Floating-point number.                                        |
346| TEXT          | 3    | String.                                        |
347| BLOB          | 4    | Uint8Array.                                    |
348| ASSET         | 5    | [Asset](arkts-apis-data-relationalStore-i.md#asset10).                             |
349| ASSETS        | 6    | [Assets](arkts-apis-data-relationalStore-t.md#assets10).                           |
350| FLOAT_VECTOR  | 7    | Float32Array.                                  |
351| UNLIMITED_INT | 8    | Bigint.                                        |
352