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 d21cba1fb9c73d01f899470b97d015b8e7ad2cd6..f91f7a53f00c1183e07f14014bfad6f489f241ca 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1338,7 +1338,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 31cae0f50a0736208404683c0accb7feeac85b17..c672898f18348a1fcf2f7302e31b8168162c2968 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -16,8 +16,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 @@ -294,10 +294,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; + }) ``` @@ -354,10 +355,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 + }) ``` @@ -388,10 +390,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; + }) ``` @@ -422,10 +425,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; + }) ``` @@ -456,10 +460,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; + }) ``` @@ -490,10 +495,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 + }) ``` @@ -783,9 +789,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 d43cc0bf6b17d7cb9c6d93adf140512a2ec4f1fc..f58bf8d37324b73d3b9b143ecec10a538730bc59 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -112,11 +112,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() + })() ``` @@ -166,9 +168,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; @@ -176,6 +179,7 @@ Reads a specified file and loads the data to the **Storage** instance for data storage.putSync('startup', 'auto') storage.flushSync() }) + })() ``` @@ -233,15 +237,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') }) + }() ```