diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index aaef7b35c12fb0246e2dd3839403c70fd26ebf3d..94e9b093900c49079f2abec3e041217170f46f70 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -1765,7 +1765,7 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A ```js let predicates = new data_rdb.RdbPredicates('EMPLOYEE') predicates.greaterThan("id", 0) -let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates) +let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]) promise.then((resultSet) => { console.info("ResultSet column names: " + resultSet.columnNames) console.info("ResultSet column count: " + resultSet.columnCount) @@ -1909,15 +1909,20 @@ beginTransaction():void **示例:** ```js -rdbStore.beginTransaction() -const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), -} -await rdbStore.insert("test", valueBucket) -rdbStore.commit() +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext() +const STORE_CONFIG = { name: "RdbTest.db"} +data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) { + rdbStore.beginTransaction() + const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), + } + await rdbStore.insert("test", valueBucket) + rdbStore.commit() +}) ``` ### commit8+ @@ -1931,16 +1936,20 @@ commit():void **示例:** ```js -rdbStore.beginTransaction() -const valueBucket = { - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), -} - -await rdbStore.insert("test", valueBucket) -rdbStore.commit() +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext() +const STORE_CONFIG = { name: "RdbTest.db"} +data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) { + rdbStore.beginTransaction() + const valueBucket = { + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), + } + await rdbStore.insert("test", valueBucket) + rdbStore.commit() +}) ``` ### rollBack8+ @@ -1954,20 +1963,25 @@ rollBack():void **示例:** ```js -try { - rdbStore.beginTransaction() - const valueBucket = { - "id": 1, - "name": "lisi", - "age": 18, - "salary": 100.5, - "blobType": new Uint8Array([1, 2, 3]), - } - await rdbStore.insert("test", valueBucket) - rdbStore.commit() -} catch (e) { - rdbStore.rollBack() -} +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext() +const STORE_CONFIG = { name: "RdbTest.db"} +data_rdb.getRdbStore(context, STORE_CONFIG, 1, async function (err, rdbStore) { + try { + rdbStore.beginTransaction() + const valueBucket = { + "id": 1, + "name": "lisi", + "age": 18, + "salary": 100.5, + "blobType": new Uint8Array([1, 2, 3]), + } + await rdbStore.insert("test", valueBucket) + rdbStore.commit() + } catch (e) { + rdbStore.rollBack() + } +}) ``` ### backup9+