提交 d179c5a8 编写于 作者: W wuyongning

Modify await

Signed-off-by: Nwuyongning <wuyongning@huawei.com>
上级 ae19b581
...@@ -84,7 +84,10 @@ ...@@ -84,7 +84,10 @@
读取指定文件,将数据加载到Storage实例,用于数据操作。 读取指定文件,将数据加载到Storage实例,用于数据操作。
``` ```
var context = featureAbility.getContext() var context = featureAbility.getContext()
var path = await context.getFilesDir() context.getFilesDir().then(() => {
console.info("======================>getFilesDirPromsie====================>");
});
let promise = dataStorage.getStorage(path + '/mystore') let promise = dataStorage.getStorage(path + '/mystore')
``` ```
......
...@@ -201,9 +201,10 @@ ...@@ -201,9 +201,10 @@
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",} const STORE_CONFIG = {name: "rdbstore.db",}
data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
let rdbStore = await data_rdb.getRdbStore(STORE_CONFIG, 1); rdbStore.executeSql(SQL_CREATE_TABLE)
await rdbStore.executeSql(CREATE_TABLE_TEST); console.info('create table done.')
})
``` ```
2. 插入数据。 2. 插入数据。
...@@ -228,16 +229,16 @@ ...@@ -228,16 +229,16 @@
``` ```
let predicates = new data_rdb.RdbPredicates("test"); let predicates = new data_rdb.RdbPredicates("test");
predicates.equalTo("name", "Tom") predicates.equalTo("name", "Tom")
let resultSet = await rdbStore.query(predicates) let promisequery = rdbStore.query(predicates)
promisequery.then((resultSet) => {
resultSet.goToFirstRow() resultSet.goToFirstRow()
const id = await resultSet.getLong(resultSet.getColumnIndex("id")) const id = resultSet.getLong(resultSet.getColumnIndex("id"))
const name = await resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = await resultSet.getLong(resultSet.getColumnIndex("age")) const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = await resultSet.getDouble(resultSet.getColumnIndex("salary")) const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = await resultSet.getBlob(resultSet.getColumnIndex("blobType")) const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
resultSet.close()
resultSet.close() })
``` ```
4. 设置分布式同步表。 4. 设置分布式同步表。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册