提交 98628437 编写于 作者: L lihuihui

rdb

Signed-off-by: Nlihuihui <lihuihui29@huawei.com>
上级 825d4e63
......@@ -245,23 +245,26 @@ class EntryAbility extends UIAbility {
}
```
## relationalStore.deleteRdbStore<sup>10+</sup>
deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<void>): void
## relationalStore.deleteRdbStore
使用指定的数据库文件配置删除数据库,使用callback异步回调。若数据库文件处于公共沙箱目录下,则删除数据库时必须使用该接口。
deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
当在公共沙箱目录下创建数据库时,必需使用该接口删除数据库
使用指定的数据库文件配置删除数据库,使用Promise异步回调
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core
**参数**
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 指定callback回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| name | string | 是 | 数据库名称。 |
**返回值**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
......@@ -271,8 +274,6 @@ deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<vo
| ------------ | ----------------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. |
| 14801001 | Only supported in stage mode. |
| 14801002 | The data group id is not valid. |
**示例:**
......@@ -282,18 +283,13 @@ FA模型示例:
import featureAbility from '@ohos.ability.featureAbility'
// 获取context
let context = featureAbility.getContext()
const STORE_CONFIG = {
name: "RdbTest.db",
securityLevel: relationalStore.SecurityLevel.S1
};
let context = featureAbility.getContext();
relationalStore.deleteRdbStore(context, STORE_CONFIG, function (err) {
if (err) {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return;
}
let promise = relationalStore.deleteRdbStore(context, "RdbTest.db");
promise.then(()=>{
console.info(`Delete RdbStore successfully.`);
}).catch((err) => {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
})
```
......@@ -304,41 +300,31 @@ import UIAbility from '@ohos.app.ability.UIAbility'
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){
const STORE_CONFIG = {
name: "RdbTest.db",
securityLevel: relationalStore.SecurityLevel.S1
};
relationalStore.deleteRdbStore(this.context, STORE_CONFIG, function (err) {
if (err) {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return;
}
let promise = relationalStore.deleteRdbStore(this.context, "RdbTest.db");
promise.then(()=>{
console.info(`Delete RdbStore successfully.`);
}).catch((err) => {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
})
}
}
```
## relationalStore.deleteRdbStore
## relationalStore.deleteRdbStore<sup>10+</sup>
deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<void>): void
使用指定的数据库文件配置删除数据库,使用Promise异步回调
使用指定的数据库文件配置删除数据库,使用callback异步回调。若数据库文件处于公共沙箱目录下,则删除数据库时必须使用该接口
**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| name | string | 是 | 数据库名称。 |
**返回值**
**参数:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义见[Context](js-apis-inner-app-context.md)<br>Stage模型的应用Context定义见[Context](js-apis-inner-application-uiAbilityContext.md)。 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 指定callback回调函数。 |
**错误码:**
......@@ -348,6 +334,8 @@ deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
| ------------ | ----------------------------------------------------------- |
| 14800010 | Failed to open or delete database by invalid database path. |
| 14800000 | Inner error. |
| 14801001 | Only supported in stage mode. |
| 14801002 | The data group id is not valid. |
**示例:**
......@@ -357,13 +345,18 @@ FA模型示例:
import featureAbility from '@ohos.ability.featureAbility'
// 获取context
let context = featureAbility.getContext();
let context = featureAbility.getContext()
const STORE_CONFIG = {
name: "RdbTest.db",
securityLevel: relationalStore.SecurityLevel.S1
};
let promise = relationalStore.deleteRdbStore(context, "RdbTest.db");
promise.then(()=>{
relationalStore.deleteRdbStore(context, STORE_CONFIG, function (err) {
if (err) {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return;
}
console.info(`Delete RdbStore successfully.`);
}).catch((err) => {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
})
```
......@@ -374,11 +367,16 @@ import UIAbility from '@ohos.app.ability.UIAbility'
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){
let promise = relationalStore.deleteRdbStore(this.context, "RdbTest.db");
promise.then(()=>{
const STORE_CONFIG = {
name: "RdbTest.db",
securityLevel: relationalStore.SecurityLevel.S1
};
relationalStore.deleteRdbStore(this.context, STORE_CONFIG, function (err) {
if (err) {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
return;
}
console.info(`Delete RdbStore successfully.`);
}).catch((err) => {
console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
})
}
}
......@@ -386,7 +384,7 @@ class EntryAbility extends UIAbility {
## relationalStore.deleteRdbStore<sup>10+</sup>
deleteRdbStore(context: Context, config: StoreConfig): Promise<void>
deleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
使用指定的数据库文件配置删除数据库,使用Promise异步回调。若数据库文件处于公共沙箱目录下,则删除数据库时必须使用该接口。
......@@ -3932,7 +3930,7 @@ try {
### on<sup>10+</sup>
on(event: string, interProcess: boolean, observer: Callback<void>): void
on(event: string, interProcess: boolean, observer: Callback\<void>): void
注册数据库的进程内或者进程间事件监听。当调用[emit](#emit10)接口时,将调用回调。
......@@ -3940,11 +3938,11 @@ on(event: string, interProcess: boolean, observer: Callback<void>): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | -------- | ---- | ------------------------------------------------------------ |
| event | string | 是 | 订阅事件名称。 |
| interProcess | boolean | 是 | 指定是进程间还是本进程订阅。<br/> true:进程间。<br/> false:本进程。 |
| observer | Callback | 是 | 回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------- | ---- | ------------------------------------------------------------ |
| event | string | 是 | 订阅事件名称。 |
| interProcess | boolean | 是 | 指定是进程间还是本进程订阅。<br/> true:进程间。<br/> false:本进程。 |
| observer | Callback\<void> | 是 | 回调函数。 |
**错误码:**
......@@ -4032,7 +4030,7 @@ try {
### off<sup>10+</sup>
off(event: string, interProcess: boolean, observer?: Callback<void>): void
off(event: string, interProcess: boolean, observer?: Callback\<void>): void
取消数据变更的事件监听。
......@@ -4040,11 +4038,11 @@ off(event: string, interProcess: boolean, observer?: Callback<void>): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | -------- | ---- | ------------------------------------------------------------ |
| event | string | 是 | 取消订阅事件名称。 |
| interProcess | boolean | 是 | 指定是进程间还是本进程取消订阅。<br/> true:进程间。<br/> false:本进程。 |
| observer | Callback | 否 | 该参数存在,则取消指定Callback监听回调,否则取消该event事件的所有监听回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------- | ---- | ------------------------------------------------------------ |
| event | string | 是 | 取消订阅事件名称。 |
| interProcess | boolean | 是 | 指定是进程间还是本进程取消订阅。<br/> true:进程间。<br/> false:本进程。 |
| observer | Callback\<void> | 否 | 该参数存在,则取消指定Callback监听回调,否则取消该event事件的所有监听回调。 |
**错误码:**
......
......@@ -128,15 +128,15 @@ Failed to obtain subscription service.
**错误描述**
进行进程间订阅时,获取订阅服务失败。
获取订阅服务失败。
**可能原因**
服务端出现异常
当前平台不支持订阅服务
**处理步骤**
通过日志信息确认错误发生原因
要在当前平台部署订阅服务
## 14801001 上下文环境非Stage模型
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册