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

!15249 [翻译完成】#I6DLSF

Merge pull request !15249 from Annie_wang/PR14184
# Distributed Data Management Subsystem JS API Changelog
## cl.distributeddatamgr.1 API Change
Changed the **relationalStore** APIs of the distributed data management (distributeddatamgr) subsystem.
Before change:
After **getRdbStore()** is called, the application determines whether the RDB store is newly created based on the **openStatus** attribute (openStatus == ON_CREATE) of the returned **rdbStore** object.
After change:
After **getRdbStore()** is called, the application determines whether the RDB store is newly created based on the **version** attribute (version == 0) of the returned **rdbStore** object.
You need to adapt your application.
**Change Impact**
The JS APIs of API version 10 are affected and need to be changed accordingly. Otherwise, certain functions cannot be properly implemented in the SDK of the new version.
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enum/Constant| Change Type|
| ------------------------------ | --------------- | ---------------- | ------- |
| @ohos.data.relationalStore | RdbStore | **openStatus: number;** is changed to **version: number;**.| Changed |
**Adaptation Guide**
Refer to the following code to set or obtain the RDB store version for an application:
```ts
const STORE_CONFIG = {
name: "rdbstore.db",
securityLevel: data_rdb.SecurityLevel.S1
}
data_rdb.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) {
// Before:
// if (rdbStore.openStatus == ON_CREATE) {
// rdbStore.executeSql("CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY AUTOINCREMENT, score REAL);", null) // create table xxx
// }
// Now:
if (rdbStore.version == 0) {
rdbStore.executeSql("CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY AUTOINCREMENT, score REAL);", null) // create table xxx
// Set the RDB store version, which is a positive integer greater than 0.
rdbStore.version == 3
}
// Obtain the RDB store version.
console.info("Get RdbStore version is " + rdbStore.version)
})
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册