diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 644c99095bc672618b63741551cbc4833e72dde5..adfc33a36ad8efa17d2593b70e1d3e0623e23467 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1336,7 +1336,7 @@ Sets the **DataAbilityPredicates** to filter out duplicate records. ``` let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") - let resultSet = await rdbStore.query(predicates, ["NAME"]) + rdbStore.query(predicates, ["NAME"]) ``` diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index eaac5db78abccd54c058d2443ef8a5f81a26f8e9..e3fc6ff3f954b818b57c59366ebe98987cca9c6c 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -750,7 +750,7 @@ Sets the **RdbPredicates** to filter out duplicate records. ``` let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") - let resultSet = await rdbStore.query(predicates, ["NAME"]) + rdbStore.query(predicates, ["NAME"]) ``` diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index 7e72ca266d54f2f9267a4c47f14da2693c81ff4f..13477856f31903eed0b080aa6e3f71b7c14a87d4 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -13,8 +13,8 @@ let predicates = new dataRdb.RdbPredicates("EMPLOYEE") predicates.equalTo("AGE", 18) let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promise.then((resultSet) => { - await console.log(TAG + "resultSet columnNames:" + resultSet.columnNames); - await console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);}) + console.log("resultSet columnNames:" + resultSet.columnNames); + console.log("resultSet columnCount:" + resultSet.columnCount); ``` ## Required Permissions @@ -291,10 +291,11 @@ Moves the cursor to the row based on the specified offset. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goTo(1) - resultSet.close() - resultSet = null + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goTo(1); + resultSet.close(); + resultSet = null; + }) ``` @@ -351,10 +352,11 @@ Moves the cursor to the specified row in the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goToRow(1) - resultSet.close() - resultSet = null + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goToRow(1); + resultSet.close(); + resultSet = null + }) ``` @@ -385,10 +387,11 @@ Moves the cursor to the first row of the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goToFirstRow() - resultSet.close() - resultSet = null; + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goToFirstRow(); + resultSet.close(); + resultSet = null; + }) ``` @@ -419,10 +422,11 @@ Moves the cursor to the last row of the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goToLastRow() - resultSet.close() - resultSet = null; + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goToLastRow(); + resultSet.close(); + resultSet = null; + }) ``` @@ -453,10 +457,11 @@ Moves the cursor to the next row in the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goToNextRow() - resultSet.close() - resultSet = null; + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goToNextRow() + resultSet.close() + resultSet = null; + }) ``` @@ -487,10 +492,11 @@ Moves the cursor to the previous row in the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.goToPreviousRow() - resultSet.close() - resultSet = null + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.goToPreviousRow(); + resultSet.close(); + resultSet = null + }) ``` @@ -780,9 +786,10 @@ Closes the result set. ``` let predicates = new dataRdb.RdbPredicates("EMPLOYEE") - let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) - resultSet.close() - resultSet = null + rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => { + resultSet.close(); + resultSet = null + }) ``` diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index e236b61478026960f226f367e4ecf3105c5f9e12..11fcd3c004306d7b779c33ac66629dd34caaa289 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -109,11 +109,13 @@ Reads a specified file and loads the data to the **Storage** instance for data import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - var context = featureAbility.getContext() - var path = await context.getFilesDir() - let storage = dataStorage.getStorageSync(path + '/mystore') - storage.putSync('startup', 'auto') - storage.flushSync() + (async () => { + var context = featureAbility.getContext() + var path = await context.getFilesDir() + let storage = dataStorage.getStorageSync(path + '/mystore') + storage.putSync('startup', 'auto') + storage.flushSync() + })() ``` @@ -163,9 +165,10 @@ Reads a specified file and loads the data to the **Storage** instance for data import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - var context = featureAbility.getContext() - var path = await context.getFilesDir() - dataStorage.getStorage(path + '/mystore', function (err, storage) { + (async () => { + var context = featureAbility.getContext() + var path = await context.getFilesDir() + dataStorage.getStorage(path + '/mystore', function (err, storage) { if (err) { console.info("Get the storage failed, path: " + path + '/mystore') return; @@ -173,6 +176,7 @@ Reads a specified file and loads the data to the **Storage** instance for data storage.putSync('startup', 'auto') storage.flushSync() }) + })() ``` @@ -230,15 +234,17 @@ Reads a specified file and loads the data to the **Storage** instance for data import dataStorage from '@ohos.data.storage' import featureAbility from '@ohos.ability.featureAbility' - var context = featureAbility.getContext() - var path = await context.getFilesDir() - let promise = dataStorage.getStorage(path + '/mystore') - promise.then((storage) => { + (async () => { + var context = featureAbility.getContext() + var path = await context.getFilesDir() + let promise = dataStorage.getStorage(path + '/mystore') + promise.then((storage) => { storage.putSync('startup', 'auto') storage.flushSync() }).catch((err) => { console.info("Get the storage failed, path: " + path + '/mystore') }) + }() ```