未验证 提交 69ef007b 编写于 作者: O openharmony_ci 提交者: Gitee

!1666 #I4TPHK已完成,请审核

Merge pull request !1666 from Annie_wang/PR1485
...@@ -1338,7 +1338,7 @@ Sets the **DataAbilityPredicates** to filter out duplicate records. ...@@ -1338,7 +1338,7 @@ Sets the **DataAbilityPredicates** to filter out duplicate records.
``` ```
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME") predicates.equalTo("NAME", "Rose").distinct("NAME")
let resultSet = await rdbStore.query(predicates, ["NAME"]) rdbStore.query(predicates, ["NAME"])
``` ```
......
...@@ -750,7 +750,7 @@ Sets the **RdbPredicates** to filter out duplicate records. ...@@ -750,7 +750,7 @@ Sets the **RdbPredicates** to filter out duplicate records.
``` ```
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME") predicates.equalTo("NAME", "Rose").distinct("NAME")
let resultSet = await rdbStore.query(predicates, ["NAME"]) rdbStore.query(predicates, ["NAME"])
``` ```
......
...@@ -16,8 +16,8 @@ let predicates = new dataRdb.RdbPredicates("EMPLOYEE") ...@@ -16,8 +16,8 @@ let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("AGE", 18) predicates.equalTo("AGE", 18)
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promise.then((resultSet) => { promise.then((resultSet) => {
await console.log(TAG + "resultSet columnNames:" + resultSet.columnNames); console.log("resultSet columnNames:" + resultSet.columnNames);
await console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);}) console.log("resultSet columnCount:" + resultSet.columnCount);
``` ```
## Required Permissions<a name="section11257113618419"></a> ## Required Permissions<a name="section11257113618419"></a>
...@@ -294,10 +294,11 @@ Moves the cursor to the row based on the specified offset. ...@@ -294,10 +294,11 @@ Moves the cursor to the row based on the specified offset.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goTo(1) resultSet.goTo(1);
resultSet.close() resultSet.close();
resultSet = null resultSet = null;
})
``` ```
...@@ -354,10 +355,11 @@ Moves the cursor to the specified row in the result set. ...@@ -354,10 +355,11 @@ Moves the cursor to the specified row in the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goToRow(1) resultSet.goToRow(1);
resultSet.close() resultSet.close();
resultSet = null resultSet = null
})
``` ```
...@@ -388,10 +390,11 @@ Moves the cursor to the first row of the result set. ...@@ -388,10 +390,11 @@ Moves the cursor to the first row of the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goToFirstRow() resultSet.goToFirstRow();
resultSet.close() resultSet.close();
resultSet = null; resultSet = null;
})
``` ```
...@@ -422,10 +425,11 @@ Moves the cursor to the last row of the result set. ...@@ -422,10 +425,11 @@ Moves the cursor to the last row of the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goToLastRow() resultSet.goToLastRow();
resultSet.close() resultSet.close();
resultSet = null; resultSet = null;
})
``` ```
...@@ -456,10 +460,11 @@ Moves the cursor to the next row in the result set. ...@@ -456,10 +460,11 @@ Moves the cursor to the next row in the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goToNextRow() resultSet.goToNextRow()
resultSet.close() resultSet.close()
resultSet = null; resultSet = null;
})
``` ```
...@@ -490,10 +495,11 @@ Moves the cursor to the previous row in the result set. ...@@ -490,10 +495,11 @@ Moves the cursor to the previous row in the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.goToPreviousRow() resultSet.goToPreviousRow();
resultSet.close() resultSet.close();
resultSet = null resultSet = null
})
``` ```
...@@ -783,9 +789,10 @@ Closes the result set. ...@@ -783,9 +789,10 @@ Closes the result set.
``` ```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE") let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
resultSet.close() resultSet.close();
resultSet = null resultSet = null
})
``` ```
...@@ -112,11 +112,13 @@ Reads a specified file and loads the data to the **Storage** instance for data ...@@ -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 dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
(async () => {
var context = featureAbility.getContext() var context = featureAbility.getContext()
var path = await context.getFilesDir() var path = await context.getFilesDir()
let storage = dataStorage.getStorageSync(path + '/mystore') let storage = dataStorage.getStorageSync(path + '/mystore')
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
storage.flushSync() storage.flushSync()
})()
``` ```
...@@ -166,6 +168,7 @@ Reads a specified file and loads the data to the **Storage** instance for data ...@@ -166,6 +168,7 @@ Reads a specified file and loads the data to the **Storage** instance for data
import dataStorage from '@ohos.data.storage' import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
(async () => {
var context = featureAbility.getContext() var context = featureAbility.getContext()
var path = await context.getFilesDir() var path = await context.getFilesDir()
dataStorage.getStorage(path + '/mystore', function (err, storage) { dataStorage.getStorage(path + '/mystore', function (err, storage) {
...@@ -176,6 +179,7 @@ Reads a specified file and loads the data to the **Storage** instance for data ...@@ -176,6 +179,7 @@ Reads a specified file and loads the data to the **Storage** instance for data
storage.putSync('startup', 'auto') storage.putSync('startup', 'auto')
storage.flushSync() storage.flushSync()
}) })
})()
``` ```
...@@ -233,6 +237,7 @@ Reads a specified file and loads the data to the **Storage** instance for data ...@@ -233,6 +237,7 @@ Reads a specified file and loads the data to the **Storage** instance for data
import dataStorage from '@ohos.data.storage' import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
(async () => {
var context = featureAbility.getContext() var context = featureAbility.getContext()
var path = await context.getFilesDir() var path = await context.getFilesDir()
let promise = dataStorage.getStorage(path + '/mystore') let promise = dataStorage.getStorage(path + '/mystore')
...@@ -242,6 +247,7 @@ Reads a specified file and loads the data to the **Storage** instance for data ...@@ -242,6 +247,7 @@ Reads a specified file and loads the data to the **Storage** instance for data
}).catch((err) => { }).catch((err) => {
console.info("Get the storage failed, path: " + path + '/mystore') console.info("Get the storage failed, path: " + path + '/mystore')
}) })
}()
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册