diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md index dcc8143e8a020dccf2fc0d59b1cdd3bad78fdda6..408d9625ce9c912c40303fea4fc8a2a825fdb998 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md @@ -17,26 +17,6 @@ import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; ``` -## uri命名规则 - -标准uri定义结构如下: - -**Scheme://authority/path** -- Scheme: 协议名,对于data share统一为datashare -- authority: [userinfo@]host[:port] - - userinfo: 登录信息,不需要填写。 - - host: 服务器地址,如果跨设备访问则为目标设备的ID,如果为本设备则为空。 - - port: 服务器端口,不需要填写。 -- path: data share的标识信息和资源的路径信息,需要包含data share的标识信息,资源的路径信息可以不填写。 - -uri示例: - -- 不包含资源路径: `datashare:///com.samples.datasharetest.DataShare` - -- 包含资源路径: `datashare:///com.samples.datasharetest.DataShare/DB00/TBL00` - -其中,data share的标识信息为`com.samples.datasharetest.DataShare`,资源路径为`DB00/TBL00`。 - ## 属性 **系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider @@ -78,7 +58,7 @@ 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}'); @@ -126,7 +106,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { 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); @@ -300,11 +280,9 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { console.info('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 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void 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 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void export default class DataShareExtAbility extends DataShareExtensionAbility { denormalizeUri(uri, callback) { let err = {'code':0}; - let ret = 'denormalize+${uri}'; + let ret = `denormalize+${uri}`; callback(err, ret); } }; diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md index 81efb644f5072a0c4a818d99111e2e76040eda66..e2769cfcb547c043656e011cc683435b0a79ea07 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @@ -593,7 +593,7 @@ let data : Array = [ {key:"empty", subscriberId:"11", data:"nobody sub"}]; let nums:number[] = [1,2,3]; function publishCallback(err, result: Array) { - console.log("publishCallback " + JSON.stringify(result)); + console.info("publishCallback " + JSON.stringify(result)); ashmem.closeAshmem(); } try { @@ -605,10 +605,10 @@ try { "data" : ashmem, "subscriberId" : "11", }); - console.log("data length is:", data.length); + console.info("data length is:", data.length); dataShareHelper.publish(data, "com.acts.ohos.data.datasharetest", version, publishCallback); } catch (e) { - console.log("publish error " + JSON.stringify(e)); + console.info("publish error " + JSON.stringify(e)); } ``` @@ -640,7 +640,7 @@ publish(data: Array<PublishedItem>, bundleName: string, callback: AsyncCal ```ts function publishCallback(err, result: Array) { - console.log("publishCallback " + JSON.stringify(result)); + console.info("publishCallback " + JSON.stringify(result)); } let data : Array = [ {key:"city", subscriberId:"11", data:"xian"}, @@ -825,7 +825,7 @@ const valueBucket = { } try { dataShareHelper.insert(uri, valueBucket).then((data) => { - console.log("insert succeed, data : " + data); + console.info("insert succeed, data : " + data); }). catch((err) => { console.error(`insert error: code: ${err.code}, message: ${err.message} `); }); @@ -902,7 +902,7 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.delete(uri, da).then((data) => { - console.log("delete succeed, data : " + data); + console.info("delete succeed, data : " + data); }). catch((err) => { console.error(`delete error: code: ${err.code}, message: ${err.message} `); }); @@ -943,7 +943,7 @@ try { console.error(`query error: code: ${err.code}, message: ${err.message} `); return; } - console.log("query succeed, rowCount : " + data.rowCount); + console.info("query succeed, rowCount : " + data.rowCount); }); } catch (err) { console.error(`query error: code: ${err.code}, message: ${err.message} `); @@ -983,7 +983,7 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.query(uri, da, columns).then((data) => { - console.log("query succeed, rowCount : " + data.rowCount); + console.info("query succeed, rowCount : " + data.rowCount); }). catch((err) => { console.error(`query error: code: ${err.code}, message: ${err.message} `); }); @@ -1029,7 +1029,7 @@ try { console.error(`update error: code: ${err.code}, message: ${err.message} `); return; } - console.log("update succeed, data : " + data); + console.info("update succeed, data : " + data); }); } catch (err) { console.error(`update error: code: ${err.code}, message: ${err.message} `); @@ -1074,7 +1074,7 @@ const va = { } try { dataShareHelper.update(uri, da, va).then((data) => { - console.log("update succeed, data : " + data); + console.info("update succeed, data : " + data); }). catch((err) => { console.error(`update error: code: ${err.code}, message: ${err.message} `); }); @@ -1112,7 +1112,7 @@ try { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); return; } - console.log("batchInsert succeed, data : " + data); + console.info("batchInsert succeed, data : " + data); }); } catch (err) { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); @@ -1149,7 +1149,7 @@ let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, {"name": "roe13", "age": 21, "salary": 20.5,}) try { dataShareHelper.batchInsert(uri, vbs).then((data) => { - console.log("batchInsert succeed, data : " + data); + console.info("batchInsert succeed, data : " + data); }). catch((err) => { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); }); @@ -1179,9 +1179,9 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri, (err, data) => { if (err !== undefined) { - console.log("normalizeUri failed, error message : " + err); + console.info("normalizeUri failed, error message : " + err); }else{ - console.log("normalizeUri = " + data); + console.info("normalizeUri = " + data); } }); ``` @@ -1211,9 +1211,9 @@ normalizeUri(uri: string): Promise<string> ```ts let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri).then((data) => { - console.log("normalizeUri = " + data); + console.info("normalizeUri = " + data); }).catch((err) => { - console.log("normalizeUri failed, error message : " + err); + console.info("normalizeUri failed, error message : " + err); }); ``` @@ -1238,9 +1238,9 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri, (err, data) => { if (err !== undefined) { - console.log("denormalizeUri failed, error message : " + err); + console.info("denormalizeUri failed, error message : " + err); }else{ - console.log("denormalizeUri = " + data); + console.info("denormalizeUri = " + data); } }); ``` @@ -1270,9 +1270,9 @@ denormalizeUri(uri: string): Promise<string> ```ts let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri).then((data) => { - console.log("denormalizeUri = " + data); + console.info("denormalizeUri = " + data); }).catch((err) => { - console.log("denormalizeUri failed, error message : " + err); + console.info("denormalizeUri failed, error message : " + err); }); ``` @@ -1296,7 +1296,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void ```ts let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.notifyChange(uri, () => { - console.log("***** notifyChange *****"); + console.info("***** notifyChange *****"); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md index 98f4dc96148332589ea8ae3ca652df0f791d09ee..676254ddfb976fdc428d09694cefa6cb46d53446 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md @@ -19,7 +19,7 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; ## DataSharePredicates 提供用于不同实现不同查询方法的数据共享谓词。该类型不是多线程安全的,如果应用中存在多线程同时操作该类派生出的实例,注意加锁保护。 -### equalTo +### equalTo10+ equalTo(field: string, value: ValueType): DataSharePredicates @@ -168,7 +168,7 @@ predicates.equalTo("NAME", "lisi") .equalTo("NAME", "Rose") ``` -### and +### and10+ and(): DataSharePredicates @@ -641,7 +641,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.lessThanOrEqualTo("AGE", 50) ``` -### orderByAsc +### orderByAsc10+ orderByAsc(field: string): DataSharePredicates @@ -670,7 +670,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.orderByAsc("AGE") ``` -### orderByDesc +### orderByDesc10+ orderByDesc(field: string): DataSharePredicates @@ -724,7 +724,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Rose").distinct() ``` -### limit +### limit10+ limit(total: number, offset: number): DataSharePredicates @@ -816,7 +816,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.indexedBy("SALARY_INDEX") ``` -### in +### in10+ in(field: string, value: Array<ValueType>): DataSharePredicates diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-valuesBucket.md b/zh-cn/application-dev/reference/apis/js-apis-data-valuesBucket.md index 422e9a5ac931cbfb34aae6a582bab357156d96a6..9f71269a09282f84ae38570686c16a94aa5332eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-valuesBucket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-valuesBucket.md @@ -4,7 +4,7 @@ > **说明:** > -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块