1# 分布式数据管理子系统JS API变更Changelog 2 3## cl.distributeddatamgr.1 接口变更 4distributeddatamgr子系统relationalStore组件接口存在变更: 5 6变更前: 7应用调用getRdbStore接口后,通过返回对象rdbStore的openStatus属性(openStatus == ON_CREATE)判断数据库是否为新创建。 8变更后: 9应用调用getRdbStore接口后,通过返回对象rdbStore的version属性(version == 0)判断数据库是否为新创建。 10 11开发者需要根据以下说明对应用进行适配。 12 13 **变更影响** 14 15影响API10版本的JS接口,应用需要进行适配才可以在新版本SDK环境正常实现功能。 16 17**关键的接口/组件变更** 18 19| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | 20| ------------------------------ | --------------- | ---------------- | ------- | 21| @ohos.data.relationalStore | RdbStore | openStatus: number; 改为 version: number; | 变更 | 22 23 24**适配指导** 25 26应用中设置和获取数据库版本可参考下列代码: 27 28```ts 29const STORE_CONFIG = { 30 name: "rdbstore.db", 31 securityLevel: data_rdb.SecurityLevel.S1 32} 33data_rdb.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) { 34 // 变更前: 35 // if (rdbStore.openStatus == ON_CREATE) { 36 // rdbStore.executeSql("CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY AUTOINCREMENT, score REAL);", null) // create table xxx 37 // } 38 39 // 变更后: 40 if (rdbStore.version == 0) { 41 rdbStore.executeSql("CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY AUTOINCREMENT, score REAL);", null) // create table xxx 42 // 设置数据库版本,值为大于0的正整数 43 rdbStore.version == 3 44 } 45 // 获取数据库版本 46 console.info("Get RdbStore version is " + rdbStore.version) 47}) 48```