提交 8335aaa5 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 81f1aeef
...@@ -227,8 +227,6 @@ ...@@ -227,8 +227,6 @@
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md) - [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md) - [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md) - [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
...@@ -436,3 +434,5 @@ ...@@ -436,3 +434,5 @@
- [PermissionDef](js-apis-bundle-PermissionDef.md) - [PermissionDef](js-apis-bundle-PermissionDef.md)
- [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md) - [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundle-ShortcutInfo.md) - [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
- data/rdb
- [resultSet (Result Set)](js-apis-data-resultset.md)
\ No newline at end of file
# @ohos.data.rdb # @ohos.data.rdb (RDB)
The relational database (RDB) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. The relational database (RDB) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
...@@ -349,6 +349,10 @@ inDevices(devices: Array&lt;string&gt;): RdbPredicates ...@@ -349,6 +349,10 @@ inDevices(devices: Array&lt;string&gt;): RdbPredicates
Sets an **RdbPredicates** to specify the remote devices to connect on the network during distributed database synchronization. Sets an **RdbPredicates** to specify the remote devices to connect on the network during distributed database synchronization.
> **NOTE**
>
> The value of **devices** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
...@@ -366,8 +370,24 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ ...@@ -366,8 +370,24 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
**Example** **Example**
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") import deviceManager from '@ohos.distributedHardware.deviceManager';
predicates.inDevices(['12345678abcde']) let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new data_rdb.RdbPredicates("EMPLOYEE");
predicates.inDevices(deviceIds);
``` ```
### inAllDevices<sup>8+</sup> ### inAllDevices<sup>8+</sup>
...@@ -1536,7 +1556,7 @@ Queries data from the RDB store based on specified conditions. This API uses a p ...@@ -1536,7 +1556,7 @@ Queries data from the RDB store based on specified conditions. This API uses a p
querySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void querySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
Queries data using the specified SQL statement. This API uses an asynchronous callback to return the result. Queries data in the RDB store using the specified SQL statement. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
...@@ -1565,7 +1585,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ...@@ -1565,7 +1585,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?",
querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;
Queries data using the specified SQL statement. This API uses a promise to return the result. Queries data in the RDB store using the specified SQL statement. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
...@@ -1619,7 +1639,7 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { ...@@ -1619,7 +1639,7 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) {
console.info("Failed to execute SQL, err: " + err) console.info("Failed to execute SQL, err: " + err)
return return
} }
console.info('Created table successfully.') console.info('Create table done.')
}) })
``` ```
...@@ -1650,7 +1670,7 @@ Executes an SQL statement that contains specified arguments but returns no value ...@@ -1650,7 +1670,7 @@ Executes an SQL statement that contains specified arguments but returns no value
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = rdbStore.executeSql(SQL_CREATE_TABLE) let promise = rdbStore.executeSql(SQL_CREATE_TABLE)
promise.then(() => { promise.then(() => {
console.info('Created table successfully.') console.info('Create table done.')
}).catch((err) => { }).catch((err) => {
console.info("Failed to execute SQL, err: " + err) console.info("Failed to execute SQL, err: " + err)
}) })
...@@ -1808,7 +1828,11 @@ promise.then(() => { ...@@ -1808,7 +1828,11 @@ promise.then(() => {
obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the distributed table name for a remote device based on the local table name. This API uses an asynchronous callback to return the result. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE**<br/>
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -1818,14 +1842,28 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1818,14 +1842,28 @@ Obtains the distributed table name for a remote device based on the local table
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | string | Yes| Remote device.| | device | string | Yes| ID of the remote device.|
| table | string | Yes| Local table name.| | table | string | Yes| Local table name of the remote device.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Example** **Example**
```js ```js
rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) { import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) {
if (err) { if (err) {
console.info('Failed to obtain DistributedTableName, err: ' + err) console.info('Failed to obtain DistributedTableName, err: ' + err)
return return
...@@ -1838,7 +1876,11 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, ...@@ -1838,7 +1876,11 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err,
obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt; obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
Obtains the distributed table name for a remote device based on the local table name. This API uses a promise to return the result. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE**<br/>
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -1848,8 +1890,8 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1848,8 +1890,8 @@ Obtains the distributed table name for a remote device based on the local table
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | string | Yes| Remote device.| | device | string | Yes| ID of the remote device.|
| table | string | Yes| Local table name.| | table | string | Yes| Local table name of the remote device.|
**Return value** **Return value**
...@@ -1860,7 +1902,20 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -1860,7 +1902,20 @@ Obtains the distributed table name for a remote device based on the local table
**Example** **Example**
```js ```js
let promise = rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE") import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
let promise = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE")
promise.then((tableName) => { promise.then((tableName) => {
console.info('Obtained distributed table name successfully, tableName= ' + tableName) console.info('Obtained distributed table name successfully, tableName= ' + tableName)
}).catch((err) => { }).catch((err) => {
...@@ -1889,8 +1944,24 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -1889,8 +1944,24 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new data_rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde']) predicates.inDevices(deviceIds)
rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
if (err) { if (err) {
console.log('Sync failed, err: ' + err) console.log('Sync failed, err: ' + err)
...@@ -1924,13 +1995,29 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -1924,13 +1995,29 @@ Synchronizes data between devices. This API uses a promise to return the result.
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to send the synchronization result. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | | Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to return the synchronization result. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new data_rdb.RdbPredicates('EMPLOYEE') let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde']) predicates.inDevices(deviceIds)
let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates) let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates)
promise.then((result) =>{ promise.then((result) =>{
console.log('Sync done.') console.log('Sync done.')
...@@ -1977,7 +2064,7 @@ try { ...@@ -1977,7 +2064,7 @@ try {
off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
Unregisters the observer of the specified type from the RDB store. This API uses an asynchronous callback to return the result. Unregisters the observer of the specified type from the RDB store. This API uses a callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
......
...@@ -399,9 +399,12 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -399,9 +399,12 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
inDevices(devices: Array&lt;string&gt;): RdbPredicates inDevices(devices: Array&lt;string&gt;): RdbPredicates
Sets an **RdbPredicates** to specify the remote devices to connect on the network during distributed database synchronization. Sets an **RdbPredicates** to specify the remote devices to connect on the network during distributed database synchronization.
> **NOTE**
>
> The value of **devices** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
...@@ -419,8 +422,24 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ ...@@ -419,8 +422,24 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.inDevices(['12345678abcde']); predicates.inDevices(deviceIds);
``` ```
### inAllDevices ### inAllDevices
...@@ -1417,7 +1436,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); ...@@ -1417,7 +1436,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.update(valueBucket, predicates, function (err, rows) { store.update(valueBucket, predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Update failed, err: ${err}`); console.error(`Updated failed, err: ${err}`);
return; return;
} }
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
...@@ -1461,7 +1480,7 @@ let promise = store.update(valueBucket, predicates); ...@@ -1461,7 +1480,7 @@ let promise = store.update(valueBucket, predicates);
promise.then(async (rows) => { promise.then(async (rows) => {
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
}).catch((err) => { }).catch((err) => {
console.error(`Update failed, err: ${err}`); console.error(`Updated failed, err: ${err}`);
}) })
``` ```
...@@ -1499,7 +1518,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); ...@@ -1499,7 +1518,7 @@ let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo("NAME", "Lisa"); predicates.equalTo("NAME", "Lisa");
store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) { store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) {
if (err) { if (err) {
console.error(`Update failed, err: ${err}`); console.error(`Updated failed, err: ${err}`);
return; return;
} }
console.info(`Updated row count: ${rows}`); console.info(`Updated row count: ${rows}`);
...@@ -1828,24 +1847,41 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A ...@@ -1828,24 +1847,41 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result. Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | | ---------- | -------------------------------------------- | ---- | --------------------------------------------------------- |
| device | string | Yes | Network ID of the remote device. | | device | string | Yes | ID of the remote device. |
| table | string | Yes | Name of the target table. | | table | string | Yes | Name of the target table. |
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. | | predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. |
| columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. |
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.greaterThan("id", 0); predicates.greaterThan("id", 0);
store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"],
function(err, resultSet) { function(err, resultSet) {
if (err) { if (err) {
console.error(`Failed to remoteQuery, err: ${err}`); console.error(`Failed to remoteQuery, err: ${err}`);
...@@ -1863,13 +1899,17 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A ...@@ -1863,13 +1899,17 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A
Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result. Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
> **NOTE**
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | ------------------------------------------------ | | ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
| device | string | Yes | Network ID of the remote device. | | device | string | Yes | ID of the remote device. |
| table | string | Yes | Name of the target table. | | table | string | Yes | Name of the target table. |
| predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. | | predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. |
| columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | Yes | Columns to query. If this parameter is not specified, the query applies to all columns.|
...@@ -1883,6 +1923,19 @@ Queries data from the RDB store of a remote device based on specified conditions ...@@ -1883,6 +1923,19 @@ Queries data from the RDB store of a remote device based on specified conditions
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.greaterThan("id", 0); predicates.greaterThan("id", 0);
let promise = store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); let promise = store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
...@@ -2308,7 +2361,11 @@ promise.then(() => { ...@@ -2308,7 +2361,11 @@ promise.then(() => {
obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the distributed table name for a remote device based on the local table name. This API uses an asynchronous callback to return the result. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE**
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -2318,14 +2375,27 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -2318,14 +2375,27 @@ Obtains the distributed table name for a remote device based on the local table
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| device | string | Yes | Remote device. | | device | string | Yes | ID of the remote device. |
| table | string | Yes | Local table name. | | table | string | Yes | Local table name of the remote device. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
**Example** **Example**
```js ```js
store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) { import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) {
if (err) { if (err) {
console.error(`ObtainDistributedTableName failed, err: ${err}`); console.error(`ObtainDistributedTableName failed, err: ${err}`);
return; return;
...@@ -2338,7 +2408,11 @@ store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tab ...@@ -2338,7 +2408,11 @@ store.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tab
obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt; obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
Obtains the distributed table name for a remote device based on the local table name. This API uses a promise to return the result. The distributed table name is required when the RDB store of a remote device is queried. Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
> **NOTE**
>
> The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -2346,10 +2420,10 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -2346,10 +2420,10 @@ Obtains the distributed table name for a remote device based on the local table
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- | | ------ | ------ | ---- | -------------------- |
| device | string | Yes | Remote device.| | device | string | Yes | ID of the remote device. |
| table | string | Yes | Local table name.| | table | string | Yes | Local table name of the remote device.|
**Return value** **Return value**
...@@ -2360,7 +2434,20 @@ Obtains the distributed table name for a remote device based on the local table ...@@ -2360,7 +2434,20 @@ Obtains the distributed table name for a remote device based on the local table
**Example** **Example**
```js ```js
let promise = store.obtainDistributedTableName("12345678abcde", "EMPLOYEE"); import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
})
let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE");
promise.then((tableName) => { promise.then((tableName) => {
console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
}).catch((err) => { }).catch((err) => {
...@@ -2389,8 +2476,24 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret ...@@ -2389,8 +2476,24 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.inDevices(['12345678abcde']); predicates.inDevices(deviceIds);
store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
if (err) { if (err) {
console.error(`Sync failed, err: ${err}`); console.error(`Sync failed, err: ${err}`);
...@@ -2429,8 +2532,24 @@ Synchronizes data between devices. This API uses a promise to return the result. ...@@ -2429,8 +2532,24 @@ Synchronizes data between devices. This API uses a promise to return the result.
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
console.log("create device manager failed, err=" + err);
return;
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.inDevices(['12345678abcde']); predicates.inDevices(deviceIds);
let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates);
promise.then((result) =>{ promise.then((result) =>{
console.info(`Sync done.`); console.info(`Sync done.`);
...@@ -2477,7 +2596,7 @@ try { ...@@ -2477,7 +2596,7 @@ try {
off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
Unregisters the observer of the specified type from the RDB store. This API uses an asynchronous callback to return the result. Unregisters the observer of the specified type from the RDB store. This API uses a callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
......
# Distributed Data Management # @ohos.data.distributedData (Distributed Data Management)
The distributed data management module implements collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to distributed databases and perform operations such as adding, deleting, modifying, querying, and synchronizing data in distributed databases. The distributed data management module implements collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to distributed databases and perform operations such as adding, deleting, modifying, querying, and synchronizing data in distributed databases.
...@@ -11,9 +11,9 @@ This module provides the following functions: ...@@ -11,9 +11,9 @@ This module provides the following functions:
- [SingleKVStore](#singlekvstore): provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore), and data is not distinguished by device. - [SingleKVStore](#singlekvstore): provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore), and data is not distinguished by device.
- [DeviceKVStore<sup>8+</sup> ](#devicekvstore8): provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore), and data is distinguished by device. - [DeviceKVStore<sup>8+</sup> ](#devicekvstore8): provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore), and data is distinguished by device.
>**NOTE**<br/> >**NOTE**
> >
>- The APIs provided by this module are no longer maintained since API version 9. You are advised to use `@ohos.data.distributedKVStore`](js-apis-distributedKVStore.md). >- The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md).
> >
>- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. >- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -119,7 +119,7 @@ Provides configuration of the **KVManager** object, including the bundle name an ...@@ -119,7 +119,7 @@ Provides configuration of the **KVManager** object, including the bundle name an
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ | | ----- | ------ | ------ | ------ |
| userInfo | [UserInfo](#userinfo) | Yes | User information.| | userInfo | [UserInfo](#userinfo) | Yes | User information.|
| bundleName | string | Yes | Bundle name.| | bundleName | string | Yes | Bundle name of the caller.|
## UserInfo ## UserInfo
...@@ -162,7 +162,7 @@ Creates and obtains a KV store. This API uses an asynchronous callback to return ...@@ -162,7 +162,7 @@ Creates and obtains a KV store. This API uses an asynchronous callback to return
| ----- | ------ | ------ | ------ | | ----- | ------ | ------ | ------ |
| storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).|
| options | [Options](#options) | Yes | Configuration of the KV store.| | options | [Options](#options) | Yes | Configuration of the KV store.|
| callback | AsyncCallback&lt;T&gt; | Yes | Callback invoked to return the KV store created.| | callback | AsyncCallback&lt;T&gt; | Yes | Callback invoked to return the KV store instance created.|
**Example** **Example**
...@@ -212,7 +212,7 @@ Creates and obtains a KV store. This API uses a promise to return the result. ...@@ -212,7 +212,7 @@ Creates and obtains a KV store. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| -------------------------------------- | ------------------------ | | -------------------------------------- | ------------------------ |
| Promise&lt;T&gt;, &lt;T extends [KVStore](#kvstore)&gt; | Promise used to return the KV store created.| | Promise&lt;T&gt;, &lt;T extends [KVStore](#kvstore)&gt; | Promise used to return the KV store instance created. |
**Example** **Example**
...@@ -449,7 +449,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) ...@@ -449,7 +449,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore)
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| appId | string | Yes | Bundle name of the app that invokes the KV store. | | appId | string | Yes | Bundle name of the app that invokes the KV store. |
| callback | AsyncCallback&lt;string[]&gt; | Yes |Callback invoked to return the KV store IDs obtained.| | callback | AsyncCallback&lt;string[]&gt; | Yes |Callback invoked to return the IDs of all created KV stores.|
**Example** **Example**
...@@ -485,7 +485,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) ...@@ -485,7 +485,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore)
| Type | Description | | Type | Description |
| ------------- | -------------- | | ------------- | -------------- |
| Promise&lt;string[]&gt;| Promise used to return the KV store IDs obtained.| | Promise&lt;string[]&gt;| Promise used to return the IDs of all created KV stores. |
**Example** **Example**
...@@ -578,7 +578,7 @@ Provides KV store configuration. ...@@ -578,7 +578,7 @@ Provides KV store configuration.
| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| backup | boolean | No|Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | backup | boolean | No|Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| autoSync | boolean | No|Whether database files are automatically synchronized. By default, database files are not automatically synchronized.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | | autoSync | boolean | No|Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC |
| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| | schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
...@@ -3074,7 +3074,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses an async ...@@ -3074,7 +3074,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses an async
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| keyPrefix |string | Yes |Key prefix to match. | | keyPrefix |string | Yes |Key prefix to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs that match the specified prefix. |
**Example** **Example**
...@@ -3125,7 +3125,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses a promis ...@@ -3125,7 +3125,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses a promis
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs obtained.| |Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs that match the specified prefix.|
**Example** **Example**
...@@ -3178,7 +3178,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an ...@@ -3178,7 +3178,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| query |[Query](#query8) | Yes |Key prefix to match. | | query |[Query](#query8) | Yes |Key prefix to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs that match the specified **Query** object. |
**Example** **Example**
...@@ -3234,7 +3234,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a ...@@ -3234,7 +3234,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs obtained.| |Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs that match the specified **Query** object.|
**Example** **Example**
...@@ -3287,7 +3287,7 @@ Obtains the result set with the specified prefix. This API uses an asynchronous ...@@ -3287,7 +3287,7 @@ Obtains the result set with the specified prefix. This API uses an asynchronous
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| keyPrefix |string | Yes |Key prefix to match.| | keyPrefix |string | Yes |Key prefix to match.|
| callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the result set obtained.| | callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the result set with the specified prefix.|
**Example** **Example**
...@@ -3341,7 +3341,7 @@ Obtains the result set with the specified prefix. This API uses a promise to ret ...@@ -3341,7 +3341,7 @@ Obtains the result set with the specified prefix. This API uses a promise to ret
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the result set obtained.| |Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the result set with the specified prefix.|
**Example** **Example**
...@@ -3571,7 +3571,7 @@ Obtains the number of results that matches the specified **Query** object. This ...@@ -3571,7 +3571,7 @@ Obtains the number of results that matches the specified **Query** object. This
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| query |[Query](#query8) | Yes |**Query** object to match. | | query |[Query](#query8) | Yes |**Query** object to match. |
| callback |AsyncCallback&lt;number&gt; | Yes |Callback invoked to return the number of results obtained. | | callback |AsyncCallback&lt;number&gt; | Yes |Callback invoked to return the number of results that match the specified **Query** object. |
**Example** **Example**
...@@ -3755,6 +3755,9 @@ try { ...@@ -3755,6 +3755,9 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
> **NOTE**
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -3771,8 +3774,41 @@ Synchronizes the KV store manually. For details about the synchronization modes ...@@ -3771,8 +3774,41 @@ Synchronizes the KV store manually. For details about the synchronization modes
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let devManager;
let kvStore; let kvStore;
kvStore.sync(['deviceIds'], distributedData.SyncMode.PULL_ONLY, 1000); const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
// create deviceManager
deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) {
devManager = value;
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
}
try {
kvStore.on('syncComplete', function (data) {
console.log('Sync dataChange');
});
kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
return;
}
console.log('Succeeded in putting data');
const mode = distributedData.SyncMode.PULL_ONLY;
kvStore.sync(deviceIds, mode, 1000);
});
} catch (e) {
console.log('Sync e' + e);
}
}
});
``` ```
### on('dataChange')<sup>8+</sup> ### on('dataChange')<sup>8+</sup>
...@@ -3884,7 +3920,7 @@ Unsubscribes from synchronization complete events. ...@@ -3884,7 +3920,7 @@ Unsubscribes from synchronization complete events.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- |
| event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.|
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for a synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. |
**Example** **Example**
...@@ -3987,7 +4023,7 @@ Obtains the security level of this KV store. This API uses an asynchronous callb ...@@ -3987,7 +4023,7 @@ Obtains the security level of this KV store. This API uses an asynchronous callb
| Name | Type| Mandatory | Description | | Name | Type| Mandatory | Description |
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| callback |AsyncCallback&lt;[SecurityLevel](#securitylevel)&gt; | Yes |Callback invoked to return the security level obtained. | | callback |AsyncCallback&lt;[SecurityLevel](#securitylevel)&gt; | Yes |Callback invoked to return the security level of the KV store. |
**Example** **Example**
...@@ -4015,7 +4051,7 @@ Obtains the security level of this KV store. This API uses a promise to return t ...@@ -4015,7 +4051,7 @@ Obtains the security level of this KV store. This API uses a promise to return t
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[SecurityLevel](#securitylevel)&gt; |Promise used to return the security level obtained.| |Promise&lt;[SecurityLevel](#securitylevel)&gt; |Promise used to return the security level of the KV store.|
**Example** **Example**
...@@ -4097,7 +4133,7 @@ Obtains a string value that matches the specified device ID and key. This API us ...@@ -4097,7 +4133,7 @@ Obtains a string value that matches the specified device ID and key. This API us
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;boolean\|string\|number\|Uint8Array&gt; |Promise used to return the string value obtained.| |Promise&lt;boolean\|string\|number\|Uint8Array&gt; |Promise used to return the string value that matches the given condition.|
**Example** **Example**
...@@ -4189,7 +4225,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API ...@@ -4189,7 +4225,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs obtained.| |Promise&lt;[Entry](#entry)[]&gt; |Promise used to return all the KV pairs that match the given condition.|
**Example** **Example**
...@@ -4299,7 +4335,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a ...@@ -4299,7 +4335,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs obtained.| |Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs that match the specified **Query** object.|
**Example** **Example**
...@@ -4353,7 +4389,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -4353,7 +4389,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| query |[Query](#query8) | Yes |**Query** object to match. | | query |[Query](#query8) | Yes |**Query** object to match. |
| callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs obtained. | | callback |AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes |Callback invoked to return the KV pairs that match the specified device ID and **Query** object. |
**Example** **Example**
...@@ -4411,7 +4447,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -4411,7 +4447,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs obtained.| |Promise&lt;[Entry](#entry)[]&gt; |Promise used to return the KV pairs that match the specified device ID and **Query** object.|
**Example** **Example**
...@@ -4466,7 +4502,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and k ...@@ -4466,7 +4502,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and k
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| keyPrefix |string | Yes |Key prefix to match. | | keyPrefix |string | Yes |Key prefix to match. |
| callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the **KvStoreResultSet** object obtained. | | callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the **KvStoreResultSet** object that matches the specified device ID and key prefix. |
**Example** **Example**
...@@ -4506,7 +4542,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and k ...@@ -4506,7 +4542,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and k
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object obtained.| |Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object that matches the specified device ID and key prefix.|
**Example** **Example**
...@@ -4601,7 +4637,7 @@ Obtains a **KvStoreResultSet** object that matches the specified **Query** objec ...@@ -4601,7 +4637,7 @@ Obtains a **KvStoreResultSet** object that matches the specified **Query** objec
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object obtained.| |Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object that matches the specified **Query** object.|
**Example** **Example**
...@@ -4661,7 +4697,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and * ...@@ -4661,7 +4697,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and *
| ----- | ------ | ---- | ----------------------- | | ----- | ------ | ---- | ----------------------- |
| deviceId |string | Yes |ID of the target device. | | deviceId |string | Yes |ID of the target device. |
| query |[Query](#query8) | Yes |**Query** object to match. | | query |[Query](#query8) | Yes |**Query** object to match. |
| callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the **KvStoreResultSet** object obtained. | | callback |AsyncCallback&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; | Yes |Callback invoked to return the **KvStoreResultSet** object that matches the specified device ID and **Query** object. |
**Example** **Example**
...@@ -4718,7 +4754,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and * ...@@ -4718,7 +4754,7 @@ Obtains a **KvStoreResultSet** object that matches the specified device ID and *
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object obtained.| |Promise&lt;[KvStoreResultSet](#kvstoreresultset8)&gt; |Promise used to return the **KvStoreResultSet** object that matches the specified device ID and **Query** object.|
**Example** **Example**
...@@ -5141,6 +5177,10 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void ...@@ -5141,6 +5177,10 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
> **NOTE**
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **System capability**: SystemCapability.DistributedDataManager.KVStore.Core
...@@ -5156,22 +5196,41 @@ Synchronizes the KV store manually. For details about the synchronization modes ...@@ -5156,22 +5196,41 @@ Synchronizes the KV store manually. For details about the synchronization modes
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let devManager;
let kvStore; let kvStore;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
try { // create deviceManager
kvStore.on('syncComplete', function (data) { deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) {
devManager = value;
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
}
try {
kvStore.on('syncComplete', function (data) {
console.log('Sync dataChange'); console.log('Sync dataChange');
}); });
kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) {
console.log('Sync put success'); if (err != undefined) {
const devices = ['deviceList']; console.log("put err: " + JSON.stringify(err));
return;
}
console.log('Succeeded in putting data');
const mode = distributedData.SyncMode.PULL_ONLY; const mode = distributedData.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode); kvStore.sync(deviceIds, mode, 1000);
}); });
}catch(e) { } catch (e) {
console.log('Sync e' + e); console.log('Sync e' + e);
} }
}
});
``` ```
### on('dataChange')<sup>8+</sup> ### on('dataChange')<sup>8+</sup>
...@@ -5283,7 +5342,7 @@ Unsubscribes from synchronization complete events. ...@@ -5283,7 +5342,7 @@ Unsubscribes from synchronization complete events.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- |
| event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.|
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for a synchronization complete event. | | syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. |
**Example** **Example**
......
...@@ -151,7 +151,7 @@ Provides KV store configuration. ...@@ -151,7 +151,7 @@ Provides KV store configuration.
| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| encrypt | boolean | No | Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | encrypt | boolean | No | Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| backup | boolean | No | Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | backup | boolean | No | Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| autoSync | boolean | No | Whether database files are automatically synchronized. By default, database files are not automatically synchronized.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC| | autoSync | boolean | No | Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC|
| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| | securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| | schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
...@@ -258,7 +258,7 @@ Creates a **KVManager** instance to manage KV stores. ...@@ -258,7 +258,7 @@ Creates a **KVManager** instance to manage KV stores.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | --------------------------------------------------------- | | ------ | ----------------------------- | ---- | --------------------------------------------------------- |
| config | [KVManagerConfig](#kvmanagerconfig) | Yes | **KVManager** instance configuration, including the bundle name and application context of the caller.| | config | [KVManagerConfig](#kvmanagerconfig) | Yes | **KVManager** instance configuration, including the bundle name and user information of the caller.|
**Return value** **Return value**
...@@ -271,7 +271,8 @@ Creates a **KVManager** instance to manage KV stores. ...@@ -271,7 +271,8 @@ Creates a **KVManager** instance to manage KV stores.
Stage model: Stage model:
```js ```js
import UIAbility from '@ohos.app.ability.UIAbility' import UIAbility from '@ohos.app.ability.UIAbility';
let kvManager; let kvManager;
export default class EntryAbility extends UIAbility { export default class EntryAbility extends UIAbility {
onCreate() { onCreate() {
...@@ -294,7 +295,7 @@ export default class EntryAbility extends UIAbility { ...@@ -294,7 +295,7 @@ export default class EntryAbility extends UIAbility {
FA model: FA model:
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility';
let kvManager; let kvManager;
let context = featureAbility.getContext() let context = featureAbility.getContext()
const kvManagerConfig = { const kvManagerConfig = {
...@@ -327,7 +328,7 @@ Creates and obtains a distributed KV store. This API uses an asynchronous callba ...@@ -327,7 +328,7 @@ Creates and obtains a distributed KV store. This API uses an asynchronous callba
| -------- | ---------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| | storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).|
| options | [Options](#options) | Yes | Configuration of the KV store to create. | | options | [Options](#options) | Yes | Configuration of the KV store to create. |
| callback | AsyncCallback&lt;T&gt; | Yes | Callback invoked to return the distributed KV store (**SingleKVStore** or **DeviceKVStore**) instance created.| | callback | AsyncCallback&lt;T&gt; | Yes | Callback invoked to return the **SingleKVStore** or **DeviceKVStore** instance created.|
**Error codes** **Error codes**
...@@ -384,7 +385,7 @@ Creates and obtains a distributed KV store. This API uses a promise to return th ...@@ -384,7 +385,7 @@ Creates and obtains a distributed KV store. This API uses a promise to return th
| Type | Description | | Type | Description |
| ---------------- | ------------------------------------------------------------ | | ---------------- | ------------------------------------------------------------ |
| Promise&lt;T&gt; | Promise used to return the distributed KV store (**SingleKVStore** or **DeviceKVStore**) instance created.| | Promise&lt;T&gt; | Promise used to return the **SingleKVStore** or **DeviceKVStore** instance created.|
**Error codes** **Error codes**
...@@ -651,7 +652,7 @@ Obtains the IDs of all distributed KV stores that are created by [getKVStore](#g ...@@ -651,7 +652,7 @@ Obtains the IDs of all distributed KV stores that are created by [getKVStore](#g
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | --------------------------------------------------- | | -------- | ----------------------------- | ---- | --------------------------------------------------- |
| appId | string | Yes | Bundle name of the app that invokes the KV store. | | appId | string | Yes | Bundle name of the app that invokes the KV store. |
| callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the IDs of the distributed KV stores obtained.| | callback | AsyncCallback&lt;string[]&gt; | Yes | Callback invoked to return the IDs of all the distributed KV stores created.|
**Example** **Example**
...@@ -689,7 +690,7 @@ Obtains the IDs of all distributed KV stores that are created by [getKVStore](#g ...@@ -689,7 +690,7 @@ Obtains the IDs of all distributed KV stores that are created by [getKVStore](#g
| Type | Description | | Type | Description |
| ----------------------- | ------------------------------------------------------ | | ----------------------- | ------------------------------------------------------ |
| Promise&lt;string[]&gt; | Promise used to return the IDs of the distributed KV stores obtained.| | Promise&lt;string[]&gt; | Promise used to return the IDs of all the distributed KV stores created. |
**Example** **Example**
...@@ -2960,7 +2961,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses an async ...@@ -2960,7 +2961,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses an async
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | -------------------------------------- | ---- | ---------------------------------------- | | --------- | -------------------------------------- | ---- | ---------------------------------------- |
| keyPrefix | string | Yes | Key prefix to match. | | keyPrefix | string | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs that match the specified prefix.|
**Error codes** **Error codes**
...@@ -3028,7 +3029,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses a promis ...@@ -3028,7 +3029,7 @@ Obtains all KV pairs that match the specified key prefix. This API uses a promis
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------- | | -------------------------------- | ------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs that match the specified prefix.|
**Error codes** **Error codes**
...@@ -3086,7 +3087,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an ...@@ -3086,7 +3087,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ----------------------------------------------- | | -------- | -------------------------------------- | ---- | ----------------------------------------------- |
| query | [Query](#query) | Yes | Key prefix to match. | | query | [Query](#query) | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs that match the specified **Query** object.|
**Error codes** **Error codes**
...@@ -3153,7 +3154,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a ...@@ -3153,7 +3154,7 @@ Obtains the KV pairs that match the specified **Query** object. This API uses a
| Type | Description | | Type | Description |
| -------------------------------- | -------------------------------------------------- | | -------------------------------- | -------------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs that match the specified **Query** object.|
**Error codes** **Error codes**
...@@ -3214,7 +3215,7 @@ Obtains a result set with the specified prefix from this single KV store. This A ...@@ -3214,7 +3215,7 @@ Obtains a result set with the specified prefix from this single KV store. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------------------------------------------- | ---- | ------------------------------------ | | --------- | ---------------------------------------------------------- | ---- | ------------------------------------ |
| keyPrefix | string | Yes | Key prefix to match. | | keyPrefix | string | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the result set obtained.| | callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the result set with the specified prefix.|
**Error codes** **Error codes**
...@@ -3288,7 +3289,7 @@ Obtains a result set with the specified prefix from this single KV store. This A ...@@ -3288,7 +3289,7 @@ Obtains a result set with the specified prefix from this single KV store. This A
| Type | Description | | Type | Description |
| ---------------------------------------------------- | --------------------------------------- | | ---------------------------------------------------- | --------------------------------------- |
| Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the result set obtained.| | Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the result set with the specified prefix.|
**Error codes** **Error codes**
...@@ -4484,6 +4485,9 @@ try { ...@@ -4484,6 +4485,9 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
> **NOTE**
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4509,26 +4513,41 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4509,26 +4513,41 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let devManager;
let kvStore; let kvStore;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
try { // create deviceManager
kvStore.on('syncComplete', function (data) { deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) {
devManager = value;
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
}
try {
kvStore.on('syncComplete', function (data) {
console.log('Sync dataChange'); console.log('Sync dataChange');
}); });
kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to sync.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Succeeded in putting data'); console.log('Succeeded in putting data');
const devices = ['deviceList'];
const mode = distributedKVStore.SyncMode.PULL_ONLY; const mode = distributedKVStore.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 1000); kvStore.sync(deviceIds, mode, 1000);
}); });
} catch (e) { } catch (e) {
console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); console.error(`Fail to sync.code is ${e.code},message is ${e.message}`);
} }
}
});
``` ```
### sync ### sync
...@@ -4536,6 +4555,9 @@ try { ...@@ -4536,6 +4555,9 @@ try {
sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md). Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview](../../database/database-mdds-overview.md).
> **NOTE**<br/>
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
...@@ -4562,29 +4584,44 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ...@@ -4562,29 +4584,44 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err
**Example** **Example**
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let devManager;
let kvStore; let kvStore;
const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; const KEY_TEST_SYNC_ELEMENT = 'key_test_sync';
const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; const VALUE_TEST_SYNC_ELEMENT = 'value-string-001';
try { // create deviceManager
kvStore.on('syncComplete', function (data) { deviceManager.createDeviceManager('bundleName', (err, value) => {
if (!err) {
devManager = value;
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
}
try {
kvStore.on('syncComplete', function (data) {
console.log('Sync dataChange'); console.log('Sync dataChange');
}); });
kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) {
if (err != undefined) { if (err != undefined) {
console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); console.error(`Fail to sync.code is ${err.code},message is ${err.message}`);
return; return;
} }
console.log('Succeeded in putting data'); console.log('Succeeded in putting data');
const devices = ['deviceList'];
const mode = distributedKVStore.SyncMode.PULL_ONLY; const mode = distributedKVStore.SyncMode.PULL_ONLY;
const query = new distributedKVStore.Query(); const query = new distributedKVStore.Query();
query.prefixKey("batch_test"); query.prefixKey("batch_test");
query.deviceId('localDeviceId'); query.deviceId('localDeviceId');
kvStore.sync(devices, query, mode, 1000); kvStore.sync(deviceIds, query, mode, 1000);
}); });
} catch (e) { } catch (e) {
console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); console.error(`Fail to sync.code is ${e.code},message is ${e.message}`);
} }
}
});
``` ```
### on('dataChange') ### on('dataChange')
...@@ -5020,7 +5057,7 @@ Obtains a string value that matches the specified device ID and key. This API us ...@@ -5020,7 +5057,7 @@ Obtains a string value that matches the specified device ID and key. This API us
| Type | Description | | Type | Description |
| ------ | ------- | | ------ | ------- |
|Promise&lt;boolean\|string\|number\|Uint8Array&gt; |Promise used to return the string value obtained.| |Promise&lt;boolean\|string\|number\|Uint8Array&gt; |Promise used to return the string value that matches the given condition.|
**Error codes** **Error codes**
...@@ -5067,7 +5104,7 @@ Obtains all KV pairs that match the specified key prefix for this device. This A ...@@ -5067,7 +5104,7 @@ Obtains all KV pairs that match the specified key prefix for this device. This A
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | -------------------------------------- | ---- | ---------------------------------------- | | --------- | -------------------------------------- | ---- | ---------------------------------------- |
| keyPrefix | string | Yes | Key prefix to match. | | keyPrefix | string | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs that match the specified prefix.|
**Error codes** **Error codes**
...@@ -5135,7 +5172,7 @@ Obtains all KV pairs that match the specified key prefix for this device. This A ...@@ -5135,7 +5172,7 @@ Obtains all KV pairs that match the specified key prefix for this device. This A
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------- | | -------------------------------- | ------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs that match the specified prefix.|
**Error codes** **Error codes**
...@@ -5263,7 +5300,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API ...@@ -5263,7 +5300,7 @@ Obtains all KV pairs that match the specified device ID and key prefix. This API
| Type | Description | | Type | Description |
| -------------------------------- | ------------------------------------------------- | | -------------------------------- | ------------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return all the KV pairs that match the given condition.|
**Error codes** **Error codes**
...@@ -5324,7 +5361,7 @@ Obtains all KV pairs that match the specified **Query** object for this device. ...@@ -5324,7 +5361,7 @@ Obtains all KV pairs that match the specified **Query** object for this device.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ----------------------------------------------------- | | -------- | -------------------------------------- | ---- | ----------------------------------------------------- |
| query | [Query](#query) | Yes | Key prefix to match. | | query | [Query](#query) | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs that match the specified **Query** object on the local device.|
**Error codes** **Error codes**
...@@ -5391,7 +5428,7 @@ Obtains all KV pairs that match the specified **Query** object for this device. ...@@ -5391,7 +5428,7 @@ Obtains all KV pairs that match the specified **Query** object for this device.
| Type | Description | | Type | Description |
| -------------------------------- | -------------------------------------------------------- | | -------------------------------- | -------------------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs that match the specified **Query** object on the local device.|
**Error codes** **Error codes**
...@@ -5453,7 +5490,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -5453,7 +5490,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| -------- | -------------------------------------- | ---- | ------------------------------------------------------- | | -------- | -------------------------------------- | ---- | ------------------------------------------------------- |
| deviceId | string | Yes | ID of the target device. | | deviceId | string | Yes | ID of the target device. |
| query | [Query](#query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs obtained.| | callback | AsyncCallback&lt;[Entry](#entry)[]&gt; | Yes | Callback invoked to return the KV pairs that match the specified device ID and **Query** object.|
**Error codes** **Error codes**
...@@ -5527,7 +5564,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th ...@@ -5527,7 +5564,7 @@ Obtains the KV pairs that match the specified device ID and **Query** object. Th
| Type | Description | | Type | Description |
| -------------------------------- | ---------------------------------------------------------- | | -------------------------------- | ---------------------------------------------------------- |
| Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs obtained.| | Promise&lt;[Entry](#entry)[]&gt; | Promise used to return the KV pairs that match the specified device ID and **Query** object.|
**Error codes** **Error codes**
...@@ -5589,7 +5626,7 @@ Obtains a result set with the specified prefix for this device. This API uses an ...@@ -5589,7 +5626,7 @@ Obtains a result set with the specified prefix for this device. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ---------------------------------------------------------- | ---- | ------------------------------------ | | --------- | ---------------------------------------------------------- | ---- | ------------------------------------ |
| keyPrefix | string | Yes | Key prefix to match. | | keyPrefix | string | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the result set obtained.| | callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the result set with the specified prefix.|
**Error codes** **Error codes**
...@@ -5663,7 +5700,7 @@ Obtains a result set with the specified prefix for this device. This API uses a ...@@ -5663,7 +5700,7 @@ Obtains a result set with the specified prefix for this device. This API uses a
| Type | Description | | Type | Description |
| ---------------------------------------------------- | --------------------------------------- | | ---------------------------------------------------- | --------------------------------------- |
| Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the result set obtained.| | Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the result set with the specified prefix.|
**Error codes** **Error codes**
...@@ -5727,7 +5764,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and k ...@@ -5727,7 +5764,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and k
| --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| deviceId | string | Yes | ID of the target device. | | deviceId | string | Yes | ID of the target device. |
| keyPrefix | string | Yes | Key prefix to match. | | keyPrefix | string | Yes | Key prefix to match. |
| callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.| | callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object that matches the specified device ID and key prefix.|
**Error codes** **Error codes**
...@@ -5783,7 +5820,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and k ...@@ -5783,7 +5820,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and k
| Type | Description | | Type | Description |
| ------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------ | ------------------------------------------------------------ |
| Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the **KVStoreResultSet** object obtained.| | Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the **KVStoreResultSet** object that matches the specified device ID and key prefix.|
**Error codes** **Error codes**
...@@ -5830,7 +5867,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and * ...@@ -5830,7 +5867,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and *
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. | | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. |
| query | [Query](#query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object obtained.| | callback | AsyncCallback&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Yes | Callback invoked to return the **KVStoreResultSet** object that matches the specified device ID and **Query** object.|
**Error codes** **Error codes**
...@@ -5907,7 +5944,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and * ...@@ -5907,7 +5944,7 @@ Obtains a **KVStoreResultSet** object that matches the specified device ID and *
| Type | Description | | Type | Description |
| ------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------ | ------------------------------------------------------------ |
| Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the **KVStoreResultSet** object obtained.| | Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the **KVStoreResultSet** object that matches the specified device ID and **Query** object.|
**Error codes** **Error codes**
...@@ -5980,7 +6017,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec ...@@ -5980,7 +6017,7 @@ Obtains a **KVStoreResultSet** object that matches the specified **Query** objec
| Type | Description | | Type | Description |
| ---------------------------------------------------- | ------------------------------------------------------------ | | ---------------------------------------------------- | ------------------------------------------------------------ |
| Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return Obtains a **KVStoreResultSet** object that matches the specified **Query** object for this device.| | Promise&lt;[KVStoreResultSet](#kvstoreresultset)&gt; | Promise used to return the **KVStoreResultSet** object obtained.|
**Error codes** **Error codes**
...@@ -6341,7 +6378,7 @@ Obtains the number of results that match the specified **Query** object for this ...@@ -6341,7 +6378,7 @@ Obtains the number of results that match the specified **Query** object for this
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------- | | -------- | --------------------------- | ---- | ------------------------------------------------- |
| query | [Query](#query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results that match the specified **Query** object.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.|
**Error codes** **Error codes**
...@@ -6404,7 +6441,7 @@ Obtains the number of results that match the specified **Query** object for this ...@@ -6404,7 +6441,7 @@ Obtains the number of results that match the specified **Query** object for this
| Type | Description | | Type | Description |
| --------------------- | ---------------------------------------------------- | | --------------------- | ---------------------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of results that match the specified **Query** object.| | Promise&lt;number&gt; | Promise used to return the number of results obtained.|
**Error codes** **Error codes**
...@@ -6463,7 +6500,7 @@ Obtains the number of results that matches the specified device ID and **Query** ...@@ -6463,7 +6500,7 @@ Obtains the number of results that matches the specified device ID and **Query**
| -------- | --------------------------- | ---- | --------------------------------------------------- | | -------- | --------------------------- | ---- | --------------------------------------------------- |
| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. | | deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs. |
| query | [Query](#query) | Yes | **Query** object to match. | | query | [Query](#query) | Yes | **Query** object to match. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the number of results obtained. |
**Error codes** **Error codes**
...@@ -6532,7 +6569,7 @@ Obtains the number of results that matches the specified device ID and **Query** ...@@ -6532,7 +6569,7 @@ Obtains the number of results that matches the specified device ID and **Query**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------ | | --------------------- | ------------------------------------------------------ |
| Promise&lt;number&gt; | Promise used to return the number of results obtained.| | Promise&lt;number&gt; | Promise used to return the number of results obtained. |
**Error codes** **Error codes**
......
...@@ -36,6 +36,7 @@ class MainAbility extends Ability { ...@@ -36,6 +36,7 @@ class MainAbility extends Ability {
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
context.getFilesDir().then((data) => { context.getFilesDir().then((data) => {
let pathDir = data; let pathDir = data;
...@@ -60,9 +61,9 @@ Obtains file information. This API uses a promise to return the result. ...@@ -60,9 +61,9 @@ Obtains file information. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.|
**Example** **Example**
...@@ -117,9 +118,9 @@ Synchronously obtains file information. ...@@ -117,9 +118,9 @@ Synchronously obtains file information.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Example** **Example**
...@@ -145,9 +146,9 @@ Opens a file directory. This API uses a promise to return the result. ...@@ -145,9 +146,9 @@ Opens a file directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------- | -------- | | -------------------------- | -------- |
| Promise&lt;[Dir](#dir)&gt; | Promise used to return the **Dir** object.| | Promise&lt;[Dir](#dir)&gt; | Promise used to return the **Dir** object.|
**Example** **Example**
...@@ -203,9 +204,9 @@ Synchronously opens a directory. ...@@ -203,9 +204,9 @@ Synchronously opens a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------- | -------- | | ----------- | -------- |
| [Dir](#dir) | A **Dir** instance corresponding to the directory.| | [Dir](#dir) | A **Dir** instance corresponding to the directory.|
**Example** **Example**
...@@ -233,9 +234,9 @@ Checks whether the current process can access a file. This API uses a promise to ...@@ -233,9 +234,9 @@ Checks whether the current process can access a file. This API uses a promise to
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -312,15 +313,15 @@ Closes a file. This API uses a promise to return the result. ...@@ -312,15 +313,15 @@ Closes a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to close.| | fd | number | Yes | File descriptor of the file to close.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -345,10 +346,10 @@ Closes a file. This API uses an asynchronous callback to return the result. ...@@ -345,10 +346,10 @@ Closes a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------ | | -------- | ------------------------- | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to close.| | fd | number | Yes | File descriptor of the file to close.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is closed asynchronously.|
**Example** **Example**
...@@ -371,9 +372,9 @@ Synchronously closes a file. ...@@ -371,9 +372,9 @@ Synchronously closes a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to close.| | fd | number | Yes | File descriptor of the file to close.|
**Example** **Example**
...@@ -394,17 +395,17 @@ Copies a file. This API uses a promise to return the result. ...@@ -394,17 +395,17 @@ Copies a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or file descriptor of the file to copy. | | src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. | | dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -429,12 +430,12 @@ Copies a file. This API uses an asynchronous callback to return the result. ...@@ -429,12 +430,12 @@ Copies a file. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------- | ---- | ---------------------------------------- | | -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or file descriptor of the file to copy. | | src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. | | dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is copied asynchronously. |
**Example** **Example**
...@@ -457,11 +458,11 @@ Synchronously copies a file. ...@@ -457,11 +458,11 @@ Synchronously copies a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | -------------------------- | ---- | ---------------------------------------- | | ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string\|number | Yes | Path or file descriptor of the file to copy. | | src | string\|number | Yes | Path or file descriptor of the file to copy. |
| dest | string\|number | Yes | Path or file descriptor of the new file. | | dest | string\|number | Yes | Path or file descriptor of the new file. |
| mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.| | mode | number | No | Option for overwriting the file of the same name in the destination path. The default value is **0**, which is the only value supported.<br>**0**: Completely overwrite the file with the same name and truncate the part that is not overwritten.|
**Example** **Example**
...@@ -489,9 +490,9 @@ Creates a directory. This API uses a promise to return the result. ...@@ -489,9 +490,9 @@ Creates a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -572,9 +573,9 @@ Opens a file. This API uses a promise to return the result. ...@@ -572,9 +573,9 @@ Opens a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ----------- | | --------------------- | ----------- |
| Promise&lt;number&gt; | Promise used to return the file descriptor of the file opened.| | Promise&lt;number&gt; | Promise used to return the file descriptor of the file opened.|
**Example** **Example**
...@@ -633,9 +634,9 @@ Synchronously opens a file. ...@@ -633,9 +634,9 @@ Synchronously opens a file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| number | File descriptor of the file opened.| | number | File descriptor of the file opened.|
**Example** **Example**
...@@ -672,9 +673,9 @@ Reads data from a file. This API uses a promise to return the result. ...@@ -672,9 +673,9 @@ Reads data from a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise used to return the data read.| | Promise&lt;[ReadOut](#readout)&gt; | Promise used to return the data read.|
**Example** **Example**
...@@ -701,12 +702,12 @@ Reads data from a file. This API uses an asynchronous callback to return the res ...@@ -701,12 +702,12 @@ Reads data from a file. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to read. | | fd | number | Yes | File descriptor of the file to read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | Yes | Callback invoked when the data is read asynchronously. | | callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | Yes | Callback invoked when the data is read asynchronously. |
**Example** **Example**
...@@ -733,17 +734,17 @@ Synchronously reads data from a file. ...@@ -733,17 +734,17 @@ Synchronously reads data from a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to read. | | fd | number | Yes | File descriptor of the file to read. |
| buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Example** **Example**
...@@ -771,9 +772,9 @@ Deletes a directory. This API uses a promise to return the result. ...@@ -771,9 +772,9 @@ Deletes a directory. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -851,9 +852,9 @@ Deletes a file. This API uses a promise to return the result. ...@@ -851,9 +852,9 @@ Deletes a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -924,17 +925,17 @@ Writes data into a file. This API uses a promise to return the result. ...@@ -924,17 +925,17 @@ Writes data into a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. | | fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Example** **Example**
...@@ -959,12 +960,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re ...@@ -959,12 +960,12 @@ Writes data into a file. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. | | fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Example** **Example**
...@@ -989,17 +990,17 @@ Synchronously writes data into a file. ...@@ -989,17 +990,17 @@ Synchronously writes data into a file.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the file to write. | | fd | number | Yes | File descriptor of the file to write. |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Example** **Example**
...@@ -1027,9 +1028,9 @@ Calculates the hash value of a file. This API uses a promise to return the resul ...@@ -1027,9 +1028,9 @@ Calculates the hash value of a file. This API uses a promise to return the resul
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------------------- | | --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.| | Promise&lt;string&gt; | Promise used to return the hash value obtained. The hash value is a hexadecimal string consisting of digits and uppercase letters.|
**Example** **Example**
...@@ -1088,9 +1089,9 @@ Changes file permissions. This API uses a promise to return the result. ...@@ -1088,9 +1089,9 @@ Changes file permissions. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1163,15 +1164,15 @@ Obtains file information based on the file descriptor. This API uses a promise t ...@@ -1163,15 +1164,15 @@ Obtains file information based on the file descriptor. This API uses a promise t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | Descriptor of the target file.| | fd | number | Yes | Descriptor of the target file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information.| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the file information obtained.|
**Example** **Example**
...@@ -1196,10 +1197,10 @@ Obtains file information based on the file descriptor. This API uses an asynchro ...@@ -1196,10 +1197,10 @@ Obtains file information based on the file descriptor. This API uses an asynchro
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------- | ---- | ---------------- | | -------- | ---------------------------------- | ---- | ---------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| callback | AsyncCallback&lt;[Stat](#stat)&gt; | Yes | Callback invoked to return the file information obtained.| | callback | AsyncCallback&lt;[Stat](#stat)&gt; | Yes | Callback invoked to return the file information obtained.|
**Example** **Example**
...@@ -1222,15 +1223,15 @@ Synchronously obtains file information based on the file descriptor. ...@@ -1222,15 +1223,15 @@ Synchronously obtains file information based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the target file.| | fd | number | Yes | File descriptor of the target file.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | File information obtained.| | [Stat](#stat) | File information obtained.|
**Example** **Example**
...@@ -1251,16 +1252,16 @@ Truncates a file based on the file descriptor. This API uses a promise to return ...@@ -1251,16 +1252,16 @@ Truncates a file based on the file descriptor. This API uses a promise to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------- | | ---- | ------ | ---- | ---------------- |
| fd | number | Yes | File descriptor of the file to truncate. | | fd | number | Yes | File descriptor of the file to truncate. |
| len | number | No | File length, in bytes, after truncation.| | len | number | No | File length, in bytes, after truncation.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1285,11 +1286,11 @@ Truncates a file based on the file descriptor. This API uses an asynchronous cal ...@@ -1285,11 +1286,11 @@ Truncates a file based on the file descriptor. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------- | | -------- | ------------------------- | ---- | ---------------- |
| fd | number | Yes | File descriptor of the file to truncate. | | fd | number | Yes | File descriptor of the file to truncate. |
| len | number | No | File length, in bytes, after truncation.| | len | number | No | File length, in bytes, after truncation.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback that returns no value. |
**Example** **Example**
...@@ -1313,10 +1314,10 @@ Synchronously truncates a file based on the file descriptor. ...@@ -1313,10 +1314,10 @@ Synchronously truncates a file based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------- | | ---- | ------ | ---- | ---------------- |
| fd | number | Yes | File descriptor of the file to truncate. | | fd | number | Yes | File descriptor of the file to truncate. |
| len | number | No | File length, in bytes, after truncation.| | len | number | No | File length, in bytes, after truncation.|
**Example** **Example**
...@@ -1345,9 +1346,9 @@ Truncates a file based on the file path. This API uses a promise to return the r ...@@ -1345,9 +1346,9 @@ Truncates a file based on the file path. This API uses a promise to return the r
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1430,9 +1431,9 @@ Reads the text content of a file. This API uses a promise to return the result. ...@@ -1430,9 +1431,9 @@ Reads the text content of a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the content read.| | Promise&lt;string&gt; | Promise used to return the content read.|
**Example** **Example**
...@@ -1489,9 +1490,9 @@ Synchronously reads the text of a file. ...@@ -1489,9 +1490,9 @@ Synchronously reads the text of a file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------- | | ------ | -------------------- |
| string | Promise used to return the content of the file read.| | string | Promise used to return the content of the file read.|
**Example** **Example**
...@@ -1517,9 +1518,9 @@ Obtains link information. This API uses a promise to return the result. ...@@ -1517,9 +1518,9 @@ Obtains link information. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------- | ---------- | | ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise used to return the link information obtained. For details, see [Stat](#stat).| | Promise&lt;[Stat](#stat)&gt; | Promise used to return the link information obtained. For details, see [Stat](#stat).|
**Example** **Example**
...@@ -1574,9 +1575,9 @@ Synchronously obtains the link information. ...@@ -1574,9 +1575,9 @@ Synchronously obtains the link information.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ---------- | | ------------- | ---------- |
| [Stat](#stat) | Link information obtained.| | [Stat](#stat) | Link information obtained.|
**Example** **Example**
...@@ -1603,9 +1604,9 @@ Renames a file. This API uses a promise to return the result. ...@@ -1603,9 +1604,9 @@ Renames a file. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1680,15 +1681,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. ...@@ -1680,15 +1681,15 @@ Flushes data of a file to disk. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to flush.| | fd | number | Yes | File descriptor of the file to flush.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1713,10 +1714,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1713,10 +1714,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------- | | -------- | ------------------------- | ---- | --------------- |
| fd | number | Yes | File descriptor of the file to flush. | | fd | number | Yes | File descriptor of the file to flush. |
| Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is synchronized in asynchronous mode.| | Callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file is synchronized in asynchronous mode.|
**Example** **Example**
...@@ -1739,9 +1740,9 @@ Flushes data of a file to disk in synchronous mode. ...@@ -1739,9 +1740,9 @@ Flushes data of a file to disk in synchronous mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to flush.| | fd | number | Yes | File descriptor of the file to flush.|
**Example** **Example**
...@@ -1762,15 +1763,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** ...@@ -1762,15 +1763,15 @@ Flushes data of a file to disk. This API uses a promise to return the result. **
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to flush.| | fd | number | Yes | File descriptor of the file to flush.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1795,10 +1796,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return ...@@ -1795,10 +1796,10 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------- | | -------- | ------------------------------- | ---- | ----------------- |
| fd | number | Yes | File descriptor of the file to synchronize. | | fd | number | Yes | File descriptor of the file to synchronize. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file data is synchronized in asynchronous mode.|
**Example** **Example**
...@@ -1821,9 +1822,9 @@ Synchronizes data in a file in synchronous mode. ...@@ -1821,9 +1822,9 @@ Synchronizes data in a file in synchronous mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the file to flush.| | fd | number | Yes | File descriptor of the file to flush.|
**Example** **Example**
...@@ -1851,9 +1852,9 @@ Creates a symbolic link based on the file path. This API uses a promise to retur ...@@ -1851,9 +1852,9 @@ Creates a symbolic link based on the file path. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -1937,9 +1938,9 @@ Changes the file owner based on the file path. This API uses a promise to return ...@@ -1937,9 +1938,9 @@ Changes the file owner based on the file path. This API uses a promise to return
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -2017,15 +2018,15 @@ Creates a temporary directory. This API uses a promise to return the result. ...@@ -2017,15 +2018,15 @@ Creates a temporary directory. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the unique directory generated.| | Promise&lt;string&gt; | Promise used to return the unique directory generated.|
**Example** **Example**
...@@ -2048,10 +2049,10 @@ Creates a temporary directory. This API uses an asynchronous callback to return ...@@ -2048,10 +2049,10 @@ Creates a temporary directory. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | --------------------------- | | -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked when a temporary directory is created asynchronously. |
**Example** **Example**
...@@ -2072,15 +2073,15 @@ Synchronously creates a temporary directory. ...@@ -2072,15 +2073,15 @@ Synchronously creates a temporary directory.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------------------- | | ------ | ------ | ---- | --------------------------- |
| prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.| | prefix | string | Yes | A randomly generated string used to replace "XXXXXX" in a directory.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | Unique path generated.| | string | Unique path generated.|
**Example** **Example**
...@@ -2099,16 +2100,16 @@ Changes file permissions based on the file descriptor. This API uses a promise t ...@@ -2099,16 +2100,16 @@ Changes file permissions based on the file descriptor. This API uses a promise t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -2134,11 +2135,11 @@ Changes file permissions based on the file descriptor. This API uses an asynchro ...@@ -2134,11 +2135,11 @@ Changes file permissions based on the file descriptor. This API uses an asynchro
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file permissions are changed asynchronously. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file permissions are changed asynchronously. |
**Example** **Example**
...@@ -2162,9 +2163,9 @@ Synchronously changes the file permissions based on the file descriptor. ...@@ -2162,9 +2163,9 @@ Synchronously changes the file permissions based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. | | mode | number | Yes | Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (&#124;).<br>- **0o700**: The owner has the read, write, and execute permissions.<br>- **0o400**: The owner has the read permission.<br>- **0o200**: The owner has the write permission.<br>- **0o100**: The owner has the execute permission.<br>- **0o070**: The user group has the read, write, and execute permissions.<br>- **0o040**: The user group has the read permission.<br>- **0o020**: The user group has the write permission.<br>- **0o010**: The user group has the execute permission.<br>- **0o007**: Other users have the read, write, and execute permissions.<br>- **0o004**: Other users have the read permission.<br>- **0o002**: Other users have the write permission.<br>- **0o001**: Other users have the execute permission. |
**Example** **Example**
...@@ -2194,9 +2195,9 @@ Opens a file stream based on the file path. This API uses a promise to return th ...@@ -2194,9 +2195,9 @@ Opens a file stream based on the file path. This API uses a promise to return th
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -2253,9 +2254,9 @@ Synchronously opens a stream based on the file path. ...@@ -2253,9 +2254,9 @@ Synchronously opens a stream based on the file path.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Example** **Example**
...@@ -2275,16 +2276,16 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret ...@@ -2275,16 +2276,16 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------- | --------- | | --------------------------------- | --------- |
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.| | Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -2309,11 +2310,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous ...@@ -2309,11 +2310,11 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. | | callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
**Example** **Example**
...@@ -2336,16 +2337,16 @@ Synchronously opens a stream based on the file descriptor. ...@@ -2336,16 +2337,16 @@ Synchronously opens a stream based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).| | mode | string | Yes | - **r**: Open a file for reading. The file must exist.<br>- **r+**: Open a file for both reading and writing. The file must exist.<br>- **w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>- **a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>- **a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | --------- | | ------------------ | --------- |
| [Stream](#stream) | Stream opened.| | [Stream](#stream) | Stream opened.|
**Example** **Example**
...@@ -2366,17 +2367,17 @@ Changes the file owner based on the file descriptor. This API uses a promise to ...@@ -2366,17 +2367,17 @@ Changes the file owner based on the file descriptor. This API uses a promise to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the target file.| | fd | number | Yes | File descriptor of the target file.|
| uid | number | Yes | New UID. | | uid | number | Yes | New UID. |
| gid | number | Yes | New GID. | | gid | number | Yes | New GID. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -2402,12 +2403,12 @@ Changes the file owner based on the file descriptor. This API uses an asynchrono ...@@ -2402,12 +2403,12 @@ Changes the file owner based on the file descriptor. This API uses an asynchrono
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------- | | -------- | ------------------------- | ---- | --------------- |
| fd | number | Yes | File descriptor of the target file. | | fd | number | Yes | File descriptor of the target file. |
| uid | number | Yes | New UID. | | uid | number | Yes | New UID. |
| gid | number | Yes | New GID. | | gid | number | Yes | New GID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file owner is changed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the file owner is changed asynchronously.|
**Example** **Example**
...@@ -2431,11 +2432,11 @@ Synchronously changes the file owner based on the file descriptor. ...@@ -2431,11 +2432,11 @@ Synchronously changes the file owner based on the file descriptor.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ | | ---- | ------ | ---- | ------------ |
| fd | number | Yes | File descriptor of the target file.| | fd | number | Yes | File descriptor of the target file.|
| uid | number | Yes | New UID. | | uid | number | Yes | New UID. |
| gid | number | Yes | New GID. | | gid | number | Yes | New GID. |
**Example** **Example**
...@@ -2465,9 +2466,9 @@ Changes the file owner (owner of the symbolic link, not the file referred to by ...@@ -2465,9 +2466,9 @@ Changes the file owner (owner of the symbolic link, not the file referred to by
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ---------------------------- | | ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
...@@ -2553,9 +2554,9 @@ Listens for file or directory changes. This API uses an asynchronous callback to ...@@ -2553,9 +2554,9 @@ Listens for file or directory changes. This API uses an asynchronous callback to
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------- | ---------- | | -------------------- | ---------- |
| [Watcher](#watcher7) | Promise used to return the **Watcher** instance.| | [Watcher](#watcher7) | Promise used to return the **Watcher** instance.|
**Example** **Example**
...@@ -2615,9 +2616,9 @@ Checks whether this file is a block special file. A block special file supports ...@@ -2615,9 +2616,9 @@ Checks whether this file is a block special file. A block special file supports
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ---------------- | | ------- | ---------------- |
| boolean | Whether the file is a block special file.| | boolean | Whether the file is a block special file.|
**Example** **Example**
...@@ -2637,9 +2638,9 @@ Checks whether this file is a character special file. A character special file s ...@@ -2637,9 +2638,9 @@ Checks whether this file is a character special file. A character special file s
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Whether the file is a character special file.| | boolean | Whether the file is a character special file.|
**Example** **Example**
...@@ -2659,9 +2660,9 @@ Checks whether this file is a directory. ...@@ -2659,9 +2660,9 @@ Checks whether this file is a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------- | | ------- | ------------- |
| boolean | Whether the file is a directory.| | boolean | Whether the file is a directory.|
**Example** **Example**
...@@ -2681,9 +2682,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int ...@@ -2681,9 +2682,9 @@ Checks whether this file is a named pipe (or FIFO). Named pipes are used for int
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------- | | ------- | --------------------- |
| boolean | Whether the file is an FIFO.| | boolean | Whether the file is an FIFO.|
**Example** **Example**
...@@ -2703,9 +2704,9 @@ Checks whether this file is a regular file. ...@@ -2703,9 +2704,9 @@ Checks whether this file is a regular file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a regular file.| | boolean | Whether the file is a regular file.|
**Example** **Example**
...@@ -2725,9 +2726,9 @@ Checks whether this file is a socket. ...@@ -2725,9 +2726,9 @@ Checks whether this file is a socket.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------- | | ------- | -------------- |
| boolean | Whether the file is a socket.| | boolean | Whether the file is a socket.|
**Example** **Example**
...@@ -2747,9 +2748,9 @@ Checks whether this file is a symbolic link. ...@@ -2747,9 +2748,9 @@ Checks whether this file is a symbolic link.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the file is a symbolic link.| | boolean | Whether the file is a symbolic link.|
**Example** **Example**
...@@ -2795,9 +2796,9 @@ Stops the **watcher** instance. This API uses an asynchronous callback to return ...@@ -2795,9 +2796,9 @@ Stops the **watcher** instance. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------- | | -------- | ------------------------- | ---- | ---------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when **watcher** is stopped asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when **watcher** is stopped asynchronously.|
**Example** **Example**
...@@ -2827,9 +2828,9 @@ Closes the stream. This API uses a promise to return the result. ...@@ -2827,9 +2828,9 @@ Closes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream close result.| | Promise&lt;void&gt; | Promise used to return the stream close result.|
**Example** **Example**
...@@ -2854,9 +2855,9 @@ Closes the stream. This API uses an asynchronous callback to return the result. ...@@ -2854,9 +2855,9 @@ Closes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------- | | -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is closed asynchronously.|
**Example** **Example**
...@@ -2896,9 +2897,9 @@ Flushes the stream. This API uses a promise to return the result. ...@@ -2896,9 +2897,9 @@ Flushes the stream. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------- | | ------------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the stream flushing result.| | Promise&lt;void&gt; | Promise used to return the stream flushing result.|
**Example** **Example**
...@@ -2923,9 +2924,9 @@ Flushes the stream. This API uses an asynchronous callback to return the result. ...@@ -2923,9 +2924,9 @@ Flushes the stream. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | -------------- | | -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the stream is asynchronously flushed.|
**Example** **Example**
...@@ -2965,16 +2966,16 @@ Writes data into the stream. This API uses a promise to return the result. ...@@ -2965,16 +2966,16 @@ Writes data into the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size |
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------- | | --------------------- | -------- |
| Promise&lt;number&gt; | Promise used to return the length of the data written.| | Promise&lt;number&gt; | Promise used to return the length of the data written.|
**Example** **Example**
...@@ -2999,11 +3000,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th ...@@ -2999,11 +3000,11 @@ Writes data into the stream. This API uses an asynchronous callback to return th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size| | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback invoked when the data is written asynchronously. |
**Example** **Example**
...@@ -3029,16 +3030,16 @@ Synchronously writes data into the stream. ...@@ -3029,16 +3030,16 @@ Synchronously writes data into the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------------------- | | ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. | | buffer | ArrayBuffer\|string | Yes | Data to write. It can be a string or data from a buffer. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position of the data to write in reference to the start address of the data. The default value is **0**.<br>- **length** (number): length of the data to write. The default value is the buffer length minus the offset.<br>- **position** (number): start position to write the data in the file. By default, data is written from the current position.<br>- **encoding** (string): format of the data to be encoded when the data is a string. The default value is **'utf-8'**, which is the only value supported.<br>Constraints: offset + length <= Buffer size |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data written in the file.| | number | Length of the data written in the file.|
**Example** **Example**
...@@ -3059,16 +3060,16 @@ Reads data from the stream. This API uses a promise to return the result. ...@@ -3059,16 +3060,16 @@ Reads data from the stream. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ------ | | ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise used to return the data read.| | Promise&lt;[ReadOut](#readout)&gt; | Promise used to return the data read.|
**Example** **Example**
...@@ -3094,11 +3095,11 @@ Reads data from the stream. This API uses an asynchronous callback to return the ...@@ -3094,11 +3095,11 @@ Reads data from the stream. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | Yes | Callback invoked when data is read asynchronously from the stream. | | callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | Yes | Callback invoked when data is read asynchronously from the stream. |
**Example** **Example**
...@@ -3124,16 +3125,16 @@ Synchronously reads data from the stream. ...@@ -3124,16 +3125,16 @@ Synchronously reads data from the stream.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ----------- | ---- | ---------------------------------------- | | ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | Yes | Buffer used to store the file read. | | buffer | ArrayBuffer | Yes | Buffer used to store the file read. |
| options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size | | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>Constraints: offset + length <= Buffer size |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------- | | ------ | -------- |
| number | Length of the data read.| | number | Length of the data read.|
**Example** **Example**
...@@ -3159,9 +3160,9 @@ Reads the next directory entry. This API uses a promise to return the result. ...@@ -3159,9 +3160,9 @@ Reads the next directory entry. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------------------------- | ------------- | | -------------------------------- | ------------- |
| Promise&lt;[Dirent](#dirent)&gt; | Promise used to return the directory entry read.| | Promise&lt;[Dirent](#dirent)&gt; | Promise used to return the directory entry read.|
**Example** **Example**
...@@ -3184,9 +3185,9 @@ Reads the next directory entry. This API uses an asynchronous callback to return ...@@ -3184,9 +3185,9 @@ Reads the next directory entry. This API uses an asynchronous callback to return
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------------------- | ---- | ---------------- | | -------- | -------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback&lt;[Dirent](#dirent)&gt; | Yes | Callback invoked when the next directory entry is asynchronously read.| | callback | AsyncCallback&lt;[Dirent](#dirent)&gt; | Yes | Callback invoked when the next directory entry is asynchronously read.|
**Example** **Example**
...@@ -3210,9 +3211,9 @@ Synchronously reads the next directory entry. ...@@ -3210,9 +3211,9 @@ Synchronously reads the next directory entry.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | -------- | | ----------------- | -------- |
| [Dirent](#dirent) | Directory entry read.| | [Dirent](#dirent) | Directory entry read.|
**Example** **Example**
...@@ -3293,9 +3294,9 @@ Checks whether this directory entry is a block special file. A block special fil ...@@ -3293,9 +3294,9 @@ Checks whether this directory entry is a block special file. A block special fil
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ---------------- | | ------- | ---------------- |
| boolean | Whether the directory entry is a block special file.| | boolean | Whether the directory entry is a block special file.|
**Example** **Example**
...@@ -3315,9 +3316,9 @@ Checks whether a directory entry is a character special file. A character specia ...@@ -3315,9 +3316,9 @@ Checks whether a directory entry is a character special file. A character specia
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------- | | ------- | ----------------- |
| boolean | Whether the directory entry is a character special file.| | boolean | Whether the directory entry is a character special file.|
**Example** **Example**
...@@ -3337,9 +3338,9 @@ Checks whether a directory entry is a directory. ...@@ -3337,9 +3338,9 @@ Checks whether a directory entry is a directory.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------- | | ------- | ------------- |
| boolean | Whether the directory entry is a directory.| | boolean | Whether the directory entry is a directory.|
**Example** **Example**
...@@ -3359,9 +3360,9 @@ Checks whether this directory entry is a named pipe (or FIFO). Named pipes are u ...@@ -3359,9 +3360,9 @@ Checks whether this directory entry is a named pipe (or FIFO). Named pipes are u
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the directory entry is a FIFO.| | boolean | Whether the directory entry is a FIFO.|
**Example** **Example**
...@@ -3381,9 +3382,9 @@ Checks whether a directory entry is a regular file. ...@@ -3381,9 +3382,9 @@ Checks whether a directory entry is a regular file.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the directory entry is a regular file.| | boolean | Whether the directory entry is a regular file.|
**Example** **Example**
...@@ -3403,9 +3404,9 @@ Checks whether a directory entry is a socket. ...@@ -3403,9 +3404,9 @@ Checks whether a directory entry is a socket.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------- | | ------- | -------------- |
| boolean | Whether the directory entry is a socket.| | boolean | Whether the directory entry is a socket.|
**Example** **Example**
...@@ -3425,9 +3426,9 @@ Checks whether a directory entry is a symbolic link. ...@@ -3425,9 +3426,9 @@ Checks whether a directory entry is a symbolic link.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------- | | ------- | --------------- |
| boolean | Whether the directory entry is a symbolic link.| | boolean | Whether the directory entry is a symbolic link.|
**Example** **Example**
......
...@@ -5,6 +5,7 @@ System capability (SysCap) refers to a relatively independent feature in the ope ...@@ -5,6 +5,7 @@ System capability (SysCap) refers to a relatively independent feature in the ope
> **NOTE** > **NOTE**
> >
> - 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. > - 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.
>
> - The APIs provided by this module are system APIs. > - The APIs provided by this module are system APIs.
...@@ -16,7 +17,7 @@ import systemcapability from '@ohos.systemCapability' ...@@ -16,7 +17,7 @@ import systemcapability from '@ohos.systemCapability'
## systemcapability.querySystemCapabilities ## systemcapability.querySystemCapabilities
querySystemCapabilities(callback: AsyncCallback<string>): void; querySystemCapabilities(callback: AsyncCallback&lt;string&gt;): void;
Queries system capabilities. This API uses an asynchronous callback to return the result. Queries system capabilities. This API uses an asynchronous callback to return the result.
...@@ -51,7 +52,7 @@ querySystemCapabilities(): Promise&lt;string&gt; ...@@ -51,7 +52,7 @@ querySystemCapabilities(): Promise&lt;string&gt;
Queries system capabilities. This API uses a promise to return the result. Queries system capabilities. This API uses a promise to return the result.
**System capability**: SystemCapability.Startup.SystemInfo **System capability**: SystemCapability.Developtools.Syscap
**Return value** **Return value**
...@@ -76,4 +77,5 @@ try { ...@@ -76,4 +77,5 @@ try {
> **NOTE** > **NOTE**
> - The system capabilities returned by the preceding APIs are in the form of an encoded numeric string. >
> The system capabilities returned by the preceding APIs are in the form of an encoded numeric string.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册