未验证 提交 915c92be 编写于 作者: 葛亚芳 提交者: Gitee

update en/application-dev/database/database-relational-guidelines.md.

Signed-off-by: N@ge-yafang <geyafang@huawei.com>
上级 acd93659
...@@ -196,7 +196,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -196,7 +196,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
import data_rdb from '@ohos.data.rdb' import data_rdb from '@ohos.data.rdb'
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)";
...@@ -213,7 +213,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -213,7 +213,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
var u8 = new Uint8Array([1, 2, 3]) var u8 = new Uint8Array([1, 2, 3])
const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,} const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,}
let insertPromise = rdbStore.insert("test", valueBucket) let insertPromise = rdbStore.insert("test", valueBucket)
...@@ -226,7 +226,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -226,7 +226,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
let predicates = new data_rdb.RdbPredicates("test"); let predicates = new data_rdb.RdbPredicates("test");
predicates.equalTo("name", "Tom") predicates.equalTo("name", "Tom")
let promisequery = rdbStore.query(predicates) let promisequery = rdbStore.query(predicates)
...@@ -247,7 +247,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -247,7 +247,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
let promise = rdbStore.setDistributedTables(["test"]) let promise = rdbStore.setDistributedTables(["test"])
promise.then(() => { promise.then(() => {
console.info("setDistributedTables success.") console.info("setDistributedTables success.")
...@@ -263,7 +263,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -263,7 +263,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
let predicate = new data_rdb.RdbPredicates('test') let predicate = new data_rdb.RdbPredicates('test')
predicate.inDevices(['12345678abcde']) predicate.inDevices(['12345678abcde'])
let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate) let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate)
...@@ -283,7 +283,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -283,7 +283,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
function storeObserver(devices) { function storeObserver(devices) {
for (let i = 0; i < devices.length; i++) { for (let i = 0; i < devices.length; i++) {
console.log('device=' + device[i] + ' data changed') console.log('device=' + device[i] + ' data changed')
...@@ -302,7 +302,7 @@ You can obtain the distributed table name for a remote device based on the local ...@@ -302,7 +302,7 @@ You can obtain the distributed table name for a remote device based on the local
The sample code is as follows: The sample code is as follows:
``` ```js
let tableName = rdbStore.obtainDistributedTableName(deviceId, "test"); let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName) let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册