提交 eab662fa 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 05cd3ae9
......@@ -17,26 +17,6 @@ The **DataShareExtensionAbility** module provides data share services based on t
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
## URI Naming Rule
The URIs are in the following format:
**Scheme://authority/path**
- *Scheme*: scheme name, which has a fixed value of **datashare** for the **DataShare** module.
- *authority*: [userinfo@]host[:port]
- *userinfo*: login information, which can be left unspecified.
- *host*: server address. It is the target device ID for cross-device access and empty for local device access.
- *port*: port number of the server, which can be left unspecified.
- *path*: **DataShare** identifier and the resource path. The **DataShare** identifier is mandatory, and the resource path is optional.
Example:
- URI without the resource path:<br>**datashare:///com.samples.datasharetest.DataShare**
- URI with the resource path:<br>**datashare:///com.samples.datasharetest.DataShare/DB00/TBL00**
**com.samples.datasharetest.DataShare** is the data share identifier, and **DB00/TBL00** is the resource path.
## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
......@@ -57,7 +37,7 @@ Called by the server to initialize service logic when the DataShare client conne
| Name| Type| Mandatory| Description|
| ----- | ------ | ------ | ------ |
| want | [Want](js-apis-application-want.md#want) | Yes | **Want** information, including the ability name and bundle name.|
| want | [Want](js-apis-application-want.md#want) | Yes | Want information, including the ability name and bundle name.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback that returns no value.|
**Example**
......@@ -78,10 +58,10 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
name: DB_NAME,
securityLevel: rdb.SecurityLevel.S1
}, function (err, data) {
console.log('getRdbStore done, data : ${data}');
console.info(`getRdbStore done, data : ${data}`);
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
console.error('executeSql done, error message : ${err}');
console.error(`executeSql done, error message : ${err}`);
});
if (callback) {
callback();
......@@ -122,11 +102,11 @@ let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
insert(uri, valueBucket, callback) {
if (valueBucket === null) {
console.info('invalid valueBuckets');
console.error('invalid valueBuckets');
return;
}
rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) {
console.info('callback ret: ${ret}');
console.info(`callback ret: ${ret}`);
if (callback !== undefined) {
callback(err, ret);
}
......@@ -256,7 +236,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
}
rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) {
if (resultSet !== undefined) {
console.info('resultSet.rowCount: ${resultSet.rowCount}');
console.info(`resultSet.rowCount: ${resultSet.rowCount}`);
}
if (callback !== undefined) {
callback(err, resultSet);
......@@ -297,14 +277,12 @@ let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
batchInsert(uri, valueBuckets, callback) {
if (valueBuckets === null || valueBuckets.length === undefined) {
console.info('invalid valueBuckets');
console.error('invalid valueBuckets');
return;
}
let resultNum = valueBuckets.length;
valueBuckets.forEach(vb => {
rdbStore.insert(TBL_NAME, vb, function (err, ret) {
rdbStore.batchInsert(TBL_NAME, valueBuckets, function (err, ret) {
if (callback !== undefined) {
callback(err, resultNum);
callback(err, ret);
}
});
});
......@@ -333,7 +311,7 @@ Normalizes a URI. This API can be overridden as required.
export default class DataShareExtAbility extends DataShareExtensionAbility {
normalizeUri(uri, callback) {
let err = {'code':0};
let ret = 'normalize+${uri}';
let ret = `normalize: ${uri}`;
callback(err, ret);
}
};
......@@ -360,7 +338,7 @@ Denormalizes a URI. This API can be overridden as required.
export default class DataShareExtAbility extends DataShareExtensionAbility {
denormalizeUri(uri, callback) {
let err = {'code':0};
let ret = 'denormalize+${uri}';
let ret = `denormalize ${uri}`;
callback(err, ret);
}
};
......
......@@ -27,7 +27,7 @@ let dataShareHelper;
let uri = ("datashare:///com.samples.datasharetest.DataShare");
await dataShare.createDataShareHelper(this.context, uri, (err, data) => {
if (err != undefined) {
console.info("createDataShareHelper fail, error message : " + err);
console.error("createDataShareHelper fail, error message : " + err);
} else {
console.info("createDataShareHelper end, data : " + data);
dataShareHelper = data;
......@@ -39,10 +39,10 @@ let da = new dataSharePredicates.DataSharePredicates();
let resultSet;
da.equalTo("name", "ZhangSan");
dataShareHelper.query(uri, da, columns).then((data) => {
console.log("query end, data : " + data);
console.info("query end, data : " + data);
resultSet = data;
}).catch((err) => {
console.log("query fail, error message : " + err);
console.error("query fail, error message : " + err);
});
```
......
......@@ -7,8 +7,7 @@ The APIs provided by **DataSharePredicates** correspond to the filter criteria
> **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 APIs provided by this module are system APIs.
## Modules to Import
......@@ -20,7 +19,7 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates';
## DataSharePredicates
Provides methods for setting different **DataSharePredicates** objects. This type is not multi-thread safe. If a **DataSharePredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
### equalTo
### equalTo<sup>10+</sup>
equalTo(field: string, value: ValueType): DataSharePredicates
......@@ -59,6 +58,7 @@ Sets a **DataSharePredicates** object to match the data that is not equal to the
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -90,6 +90,7 @@ Adds a left parenthesis to this **DataSharePredicates**.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -119,6 +120,7 @@ Adds a right parenthesis to this **DataSharePredicates** object.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -148,6 +150,7 @@ Adds the OR condition to this **DataSharePredicates** object.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -165,7 +168,7 @@ predicates.equalTo("NAME", "lisi")
.equalTo("NAME", "Rose")
```
### and
### and<sup>10+</sup>
and(): DataSharePredicates
......@@ -199,6 +202,7 @@ Sets a **DataSharePredicates** object to match the data that contains the specif
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -230,6 +234,7 @@ Sets a **DataSharePredicates** object to match the data that begins with the spe
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -261,6 +266,7 @@ Sets a **DataSharePredicates** object to match the data that ends with the speci
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -292,6 +298,7 @@ Sets a **DataSharePredicates** object to match the data whose value is null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -322,6 +329,7 @@ Sets a **DataSharePredicates** object to match the data whose value is not null.
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -352,6 +360,7 @@ Sets a **DataSharePredicates** object to match the data that matches the specifi
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -383,6 +392,7 @@ Sets a **DataSharePredicates** object to match the data that does not match the
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -414,6 +424,7 @@ Sets a **DataSharePredicates** object to match the data that matches the specifi
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -445,6 +456,7 @@ Sets a **DataSharePredicates** object to match the data that is within the speci
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -477,6 +489,7 @@ Sets a **DataSharePredicates** object to match the data that is out of the speci
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -509,6 +522,7 @@ Sets a **DataSharePredicates** object to match the data that is greater than the
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -540,6 +554,7 @@ Sets a **DataSharePredicates** object to match the data that is less than the sp
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -571,6 +586,7 @@ Sets a **DataSharePredicates** object to match the data that is greater than or
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -602,6 +618,7 @@ Sets a **DataSharePredicates** object to match the data that is less than or equ
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -624,7 +641,7 @@ let predicates = new dataSharePredicates.DataSharePredicates()
predicates.lessThanOrEqualTo("AGE", 50)
```
### orderByAsc
### orderByAsc<sup>10+</sup>
orderByAsc(field: string): DataSharePredicates
......@@ -653,7 +670,7 @@ let predicates = new dataSharePredicates.DataSharePredicates()
predicates.orderByAsc("AGE")
```
### orderByDesc
### orderByDesc<sup>10+</sup>
orderByDesc(field: string): DataSharePredicates
......@@ -691,6 +708,7 @@ Sets a **DataSharePredicates** object to filter out duplicate data records.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
......@@ -706,7 +724,7 @@ let predicates = new dataSharePredicates.DataSharePredicates()
predicates.equalTo("NAME", "Rose").distinct()
```
### limit
### limit<sup>10+</sup>
limit(total: number, offset: number): DataSharePredicates
......@@ -745,6 +763,7 @@ Sets a **DataSharePredicates** object group the records according to the specifi
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -775,6 +794,7 @@ Sets a **DataSharePredicates** object to list data by the specified index.
Currently, only the RDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -796,7 +816,7 @@ let predicates = new dataSharePredicates.DataSharePredicates()
predicates.indexedBy("SALARY_INDEX")
```
### in
### in<sup>10+</sup>
in(field: string, value: Array&lt;ValueType&gt;): DataSharePredicates
......@@ -835,6 +855,7 @@ Sets a **DataSharePredicates** object to match the data that is not in the speci
Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -866,6 +887,7 @@ Sets a **DataSharePredicates** object to match the data with the specified key p
Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......@@ -896,6 +918,7 @@ Sets a **DataSharePredicates** object to match the data whose keys are within th
Currently, only the KVDB supports this **DataSharePredicates** object.
**System API**: This is a system API.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
......
......@@ -4,8 +4,7 @@ The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to
> **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 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册