关系型数据库(Relational Database,RDB)是一种基于关系模子来管理数据的数据库。关系型数据库基于SQLite组件提供了一套完整的对当地数据库举行管理的机制,对外提供了一系列的增、删、改、查等接口,也可以直接运行用户输入的SQL语句来满意复杂的场景需要。不支持Worker线程。 ArkTS侧支持的基本数据类型:number、string、二进制类型数据、boolean。为保证插入并读取数据成功,发起一条数据不要超过2M。超出该大小,插入成功,读取失败。
该模块提供以下关系型数据库相关的常勤奋能:
- RdbPredicates: 数据库中用来代表数据实体的性子、特性或者数据实体之间关系的词项,主要用来界说数据库的操作条件。
- RdbStore:提供管理关系数据库(RDB)方法的接口。
- ResultSet:提供用户调用关系型数据库查询接口之后返回的结果集合。
分析:
本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
导入模块
- import relationalStore from '@ohos.data.relationalStore';复制到剪贴板错误复制
复制代码 relationalStore.getRdbStore
getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void
获得一个相关的RdbStore,操作关系型数据库,用户可以根据本身的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以实行相关的数据操作,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。configStoreConfig是与此RDB存储相关的数据库配置。回调AsyncCallback<RdbStore>是指定callback回调函数,返回RdbStore对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800011Failed to open database by database corrupted.14800000Inner error.14801001Only supported in stage mode.14801002The data group id is not valid. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
- store = rdbStore;
- if (err) {
- console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Get RdbStore successfully.');
- })复制到剪贴板错误复制
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage) {
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
-
- relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
- store = rdbStore;
- if (err) {
- console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Get RdbStore successfully.');
- })
- }
- }复制到剪贴板错误复制
复制代码 relationalStore.getRdbStore
getRdbStore(context: Context, config: StoreConfig): Promise<RdbStore>
获得一个相关的RdbStore,操作关系型数据库,用户可以根据本身的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以实行相关的数据操作,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。configStoreConfig是与此RDB存储相关的数据库配置。 返回值:
类型分析Promise<RdbStore>Promise对象。返回RdbStore对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800011Failed to open database by database corrupted.14800000Inner error.14801001Only supported in stage mode.14801002The data group id is not valid. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
- store = rdbStore;
- console.info('Get RdbStore successfully.')
- }).catch((err: BusinessError) => {
- console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
- })Copy to clipboardErrorCopied
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage) {
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(this.context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
- store = rdbStore;
- console.info('Get RdbStore successfully.')
- }).catch((err: BusinessError) => {
- console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
- })
- }
- }Copy to clipboardErrorCopied
复制代码 relationalStore.deleteRdbStore
deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void
删除数据库文件,利用callback异步回调。
删除成功后,发起将数据库对象置为null。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。namestring是数据库名称。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800000Inner error. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- relationalStore.deleteRdbStore(context, "RdbTest.db", (err: BusinessError) => {
- if (err) {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store = undefined;
- console.info('Delete RdbStore successfully.');
- })Copy to clipboardErrorCopied
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage){
- relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError) => {
- if (err) {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store = undefined;
- console.info('Delete RdbStore successfully.');
- })
- }
- }Copy to clipboardErrorCopied
复制代码 relationalStore.deleteRdbStore
deleteRdbStore(context: Context, name: string): Promise<void>
利用指定的数据库文件配置删除数据库,利用Promise异步回调。
删除成功后,发起将数据库对象置为null。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。namestring是数据库名称。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800000Inner error. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- relationalStore.deleteRdbStore(context, "RdbTest.db").then(()=>{
- store = undefined;
- console.info('Delete RdbStore successfully.');
- }).catch((err: BusinessError) => {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- })Copy to clipboardErrorCopied
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage){
- relationalStore.deleteRdbStore(this.context, "RdbTest.db").then(()=>{
- store = undefined;
- console.info('Delete RdbStore successfully.');
- }).catch((err: BusinessError) => {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- })
- }
- }
复制代码 relationalStore.deleteRdbStore10+
deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<void>): void
利用指定的数据库文件配置删除数据库,利用callback异步回调。
删除成功后,发起将数据库对象置为null。若数据库文件处于公共沙箱目录下,则删除数据库时必须利用该接口,当存在多个历程操作同一个数据库的情况,发起向其他历程发送数据库删除关照使其感知并处理。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。configStoreConfig是与此RDB存储相关的数据库配置。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800000Inner error.14801001Only supported in stage mode.14801002The data group id is not valid. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.deleteRdbStore(context, STORE_CONFIG, (err: BusinessError) => {
- if (err) {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store = undefined;
- console.info('Delete RdbStore successfully.');
- })Copy to clipboardErrorCopied
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage){
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError) => {
- if (err) {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store = undefined;
- console.info('Delete RdbStore successfully.');
- })
- }
- }
- Copy to clipboardErrorCopied
复制代码 relationalStore.deleteRdbStore10+
deleteRdbStore(context: Context, config: StoreConfig): Promise<void>
利用指定的数据库文件配置删除数据库,利用Promise异步回调。
删除成功后,发起将数据库对象置为null。若数据库文件处于公共沙箱目录下,则删除数据库时必须利用该接口,当存在多个历程操作同一个数据库的情况,发起向其他历程发送数据库删除关照使其感知并处理。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数
参数名类型必填分析contextContext是应用的上下文。
FA模子的应用Context界说见Context。
Stage模子的应用Context界说见Context。configStoreConfig是与此RDB存储相关的数据库配置。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800010Failed to open or delete database by invalid database path.14800000Inner error.14801001Only supported in stage mode.14801002The data group id is not valid. 示例:
FA模子示例:
- import featureAbility from '@ohos.ability.featureAbility';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- let context = getContext(this);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.deleteRdbStore(context, STORE_CONFIG).then(()=>{
- store = undefined;
- console.info('Delete RdbStore successfully.');
- }).catch((err: BusinessError) => {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- })Copy to clipboardErrorCopied
复制代码 Stage模子示例:
- import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
- import { BusinessError } from "@ohos.base";
- let store: relationalStore.RdbStore | undefined = undefined;
- class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage){
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.deleteRdbStore(this.context, STORE_CONFIG).then(()=>{
- store = undefined;
- console.info('Delete RdbStore successfully.');
- }).catch((err: BusinessError) => {
- console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
- })
- }
- }Copy to clipboardErrorCopied
复制代码 StoreConfig
管理关系数据库配置。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析namestring是数据库文件名。securityLevelSecurityLevel是设置数据库安全级别encryptboolean否指定命据库是否加密,默认不加密。
true:加密。
false:非加密。dataGroupId10+string否应用组ID,需要向应用市场获取。
模子约束: 此属性仅在Stage模子下可用。
从API version 10开始,支持此可选参数。指定在此dataGroupId对应的沙箱路径下创建relationalStore实例,当此参数不填时,默认在本应用沙箱目录下创建relationalStore实例。 SecurityLevel
数据库的安全级别枚举。请利用枚举名称而非枚举值。
分析:
若需要举行同步操作,数据库安全等级应不高于对端装备安全等级,具体可见跨装备同步访问控制机制。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称值分析S11表现数据库的安全级别为低级别,当数据泄露时会产生较低影响。例如,包罗壁纸等体系数据的数据库。S22表现数据库的安全级别为中级别,当数据泄露时会产生较大影响。例如,包罗录音、视频等用户生成数据或通话记录等信息的数据库。S33表现数据库的安全级别为高级别,当数据泄露时会产生庞大影响。例如,包罗用户活动、康健、位置等信息的数据库。S44表现数据库的安全级别为关键级别,当数据泄露时会产生严峻影响。例如,包罗认证凭据、财务数据等信息的数据库。 AssetStatus10+
描述资产附件的状态枚举。请利用枚举名称而非枚举值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称值分析ASSET_NORMAL1表现资产状态正常。ASSET_INSERT2表现资产需要插入到云端。ASSET_UPDATE3表现资产需要更新到云端。ASSET_DELETE4表现资产需要在云端删除。ASSET_ABNORMAL5表现资产状态非常。ASSET_DOWNLOADING6表现资产正在下载到当地装备。 Asset10+
记录资产附件(文件、图片、视频等类型文件)的相关信息。资产类型的相关接口暂不支持Datashare。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析namestring是资产的名称。uristring是资产的uri,在体系里的绝对路径。pathstring是资产在应用沙箱里的路径。createTimestring是资产被创建出来的时间。modifyTimestring是资产末了一次被修改的时间。sizestring是资产占用空间的大小。statusAssetStatus否资产的状态,默认值为ASSET_NORMAL。 Assets10+
表现Asset类型的数组。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
类型分析Asset[]表现Asset类型的数组。 ValueType
用于表现允许的数据字段类型,接口参数具体类型根据其功能而定。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
类型分析null10+表现值类型为空。number表现值类型为数字。string表现值类型为字符。boolean表现值类型为布尔值。Uint8Array10+表现值类型为Uint8类型的数组。Asset10+表现值类型为附件Asset。Assets10+表现值类型为附件数组Assets。 ValuesBucket
用于存储键值对的类型。该类型不是多线程安全的,如果应用中存在多线程同时操作该类派生出的实例,注意加锁掩护。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
键类型值类型number主键的类型可以是numberstring主键的类型可以是string。 PRIKeyType10+
用于表现数据库表某一行主键的数据类型。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
类型分析number主键的类型可以是number。string主键的类型可以是string。 UTCTime10+
用于表现UTC类型时间的数据类型。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
类型分析DateUTC类型的时间。 ModifyTime10+
用于存储数据库表的主键和修改时间的数据类型。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
类型分析Map< RIKeyType, UTCTime>键表现是数据库表某一行的主键,值表现该行的末了修改时间,用UTC格式表现。 SyncMode
指数据库同步模式。请利用枚举名称而非枚举值。
名称值分析SYNC_MODE_PUSH0表现数据从当地装备推送到远程装备。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.CoreSYNC_MODE_PULL1表现数据从远程装备拉至当地装备。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.CoreSYNC_MODE_TIME_FIRST10+4表现数据从修改时间较近的一端同步到修改时间较远的一端。
体系能力: SystemCapability.DistributedDataManager.CloudSync.ClientSYNC_MODE_NATIVE_FIRST10+5表现数据从当地装备同步到云端。
体系能力: SystemCapability.DistributedDataManager.CloudSync.ClientSYNC_MODE_CLOUD_FIRST10+6表现数据从云端同步到当地装备。
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client SubscribeType
描述订阅类型。请利用枚举名称而非枚举值。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
名称值分析SUBSCRIBE_TYPE_REMOTE0订阅远程数据更改。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.CoreSUBSCRIBE_TYPE_CLOUD10+1订阅云端数据更改。
体系能力: SystemCapability.DistributedDataManager.CloudSync.ClientSUBSCRIBE_TYPE_CLOUD_DETAILS10+2订阅云端数据更改详情。
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client ChangeType10+
描述数据变更类型的枚举。请利用枚举名称而非枚举值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
名称值分析DATA_CHANGE0表现是数据发生变更。ASSET_CHANGE1表现是资产附件发生了变更。 ChangeInfo10+
记录端云同步过程详情。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析tablestring是表现发生变化的表的名称。typeChangeType是表现发生变化的数据的类型,数据或者资产附件发生变化。insertedArray<string> | Array<number>是记录插入数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表现插入数据的行号。updatedArray<string> | Array<number>是记录更新数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表现更新数据的行号。deletedArray<string> | Array<number>是记录删除数据的位置,如果该表的主键是string类型,该值是主键的值,否则该值表现删除数据的行号。 DistributedType10+
描述表的分布式类型的枚举。请利用枚举名称而非枚举值。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
名称值分析DISTRIBUTED_DEVICE0表如今不同装备之间分布式的数据库表。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.CoreDISTRIBUTED_CLOUD1表如今装备和云端之间分布式的数据库表。
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client DistributedConfig10+
记录表的分布式配置信息。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析autoSyncboolean是该值为true时,表现该表支持自动同步和手动同步;该值为false时,表现该表只支持手动同步,不支持自动同步。 ConflictResolution10+
插入和修改接口的冲突解决方式。请利用枚举名称而非枚举值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称值分析ON_CONFLICT_NONE0表现当冲突发生时,不做任那边理。ON_CONFLICT_ROLLBACK1表现当冲突发生时,中止SQL语句并回滚当前事务。ON_CONFLICT_ABORT2表现当冲突发生时,中止当前SQL语句,并打消当前 SQL 语句所做的任何更改,但是由同一事务中先前的 SQL 语句引起的更改被生存而且事务保持活动状态。ON_CONFLICT_FAIL3表现当冲突发生时,中止当前 SQL 语句。但它不会打消失败的 SQL 语句的先前更改,也不会竣事事务。ON_CONFLICT_IGNORE4表现当冲突发生时,跳过包罗违背约束的行并继续处理 SQL 语句的后续行。ON_CONFLICT_REPLACE5表现当冲突发生时,在插入或更新当前行之前删除导致约束违例的预先存在的行,而且下令会继续正常实行。 Progress10+
描述端云同步过程的枚举。请利用枚举名称而非枚举值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称值分析SYNC_BEGIN0表现端云同步过程开始。SYNC_IN_PROGRESS1表现正在端云同步过程中。SYNC_FINISH2表现端云同步过程已完成。 Statistic10+
描述数据库表的端云同步过程的统计信息。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析totalnumber是表现数据库表中需要端云同步的总行数。successfulnumber是表现数据库表中端云同步成功的行数。failednumber是表现数据库表中端云同步失败的行数。remainednumber是表现数据库表中端云同步剩余未实行的行数。 TableDetails10+
描述数据库表实行端云同步使命上传和下载的统计信息。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析uploadStatistic是表现数据库表中端云同步上传过程的统计信息。downloadStatistic是表现数据库表中端云同步下载过程的统计信息。 ProgressCode10+
表现端云同步过程的状态。请利用枚举名称而非枚举值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称值分析SUCCESS0表现端云同步过程成功。UNKNOWN_ERROR1表现端云同步过程遇到未知错误。NETWORK_ERROR2表现端云同步过程遇到网络错误。CLOUD_DISABLED3表现云端不可用。LOCKED_BY_OTHERS4表现有其他装备正在端云同步,本装备无法举行端云同步。
请确保无其他装备占用云端资源后,再利用本装备举行端云同步使命。RECORD_LIMIT_EXCEEDED5表现本次端云同步需要同步的条目或大小超出最大值。由云端配置最大值。NO_SPACE_FOR_ASSET6表现云空间剩余空间小于待同步的资产大小。 ProgressDetails10+
描述数据库团体实行端云同步使命上传和下载的统计信息。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析scheduleProgress是表现端云同步过程。codeProgressCode是表现端云同步过程的状态。details[table: string] : TableDetails是表现端云同步各表的统计信息。
键表现表名,值表现该表的端云同步过程统计信息。 RdbPredicates
表现关系型数据库(RDB)的谓词。该类确定RDB中条件表达式的值是true照旧false。该类型不是多线程安全的,如果应用中存在多线程同时操作该类派生出的实例,注意加锁掩护。
constructor
constructor(name: string)
构造函数。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析namestring是数据库表名。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");Copy to clipboardErrorCopied
复制代码 inDevices
inDevices(devices: Array<string>): RdbPredicates
同步分布式数据库时毗连到组网内指定的远程装备。
分析:
其中devices通过调用deviceManager.getAvailableDeviceListSync方法得到。 数据库同步时调用Sync接口,需要在入参谓词中调用inDevices接口选择装备。如果不调用inDevices接口即默认毗连组网内所有的装备。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析devicesArray<string>是指定的组网内的远程装备ID。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- let dmInstance: deviceManager.DeviceManager;
- let deviceIds: Array<string> = [];
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
- for (let i = 0; i < devices.length; i++) {
- deviceIds[i] = devices[i].networkId!;
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.inDevices(deviceIds);
- if(store != undefined) {
- // 设置数据库版本
- (store as relationalStore.RdbStore).version = 3;
- // 获取数据库版本
- console.info(`RdbStore version is ${(store as relationalStore.RdbStore).version}`);
- }Copy to clipboardErrorCopied
复制代码 inAllDevices
inAllDevices(): RdbPredicates
同步分布式数据库时毗连到组网内所有的远程装备。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.inAllDevices();Copy to clipboardErrorCopied
复制代码 equalTo
equalTo(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值为value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中值为"Lisa"的字段
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");Copy to clipboardErrorCopied
复制代码 notEqualTo
notEqualTo(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值不为value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中值不为"Lisa"的字段
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.notEqualTo("NAME", "Lisa");Copy to clipboardErrorCopied
复制代码 beginWrap
beginWrap(): RdbPredicates
向谓词添加左括号。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回带有左括号的Rdb谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa")
- .beginWrap()
- .equalTo("AGE", 18)
- .or()
- .equalTo("SALARY", 200.5)
- .endWrap()Copy to clipboardErrorCopied
复制代码 endWrap
endWrap(): RdbPredicates
向谓词添加右括号。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回带有右括号的Rdb谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa")
- .beginWrap()
- .equalTo("AGE", 18)
- .or()
- .equalTo("SALARY", 200.5)
- .endWrap()Copy to clipboardErrorCopied
复制代码 or
or(): RdbPredicates
将或条件添加到谓词中。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回带有或条件的Rdb谓词。 示例:
- // 匹配数据表的"NAME"列中值为"Lisa"或"Rose"的字段
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa")
- .or()
- .equalTo("NAME", "Rose")Copy to clipboardErrorCopied
复制代码 and
and(): RdbPredicates
向谓词添加和条件。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回带有和条件的Rdb谓词。 示例:
- // 匹配数据表的"NAME"列中值为"Lisa"且"SALARY"列中值为"200.5"的字段
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa")
- .and()
- .equalTo("SALARY", 200.5)Copy to clipboardErrorCopied
复制代码 contains
contains(field: string, value: string): RdbPredicates
配置谓词以匹配数据表的field列中包罗value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valuestring是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中包含"os"的字段,如"Rose"
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.contains("NAME", "os");Copy to clipboardErrorCopied
复制代码 beginsWith
beginsWith(field: string, value: string): RdbPredicates
配置谓词以匹配数据表的field列中以value开头的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valuestring是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中以"Li"开头的字段,如"Lisa"
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.beginsWith("NAME", "Li");Copy to clipboardErrorCopied
复制代码 endsWith
endsWith(field: string, value: string): RdbPredicates
配置谓词以匹配数据表的field列中以value末端的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valuestring是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中以"se"结尾的字段,如"Rose"
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.endsWith("NAME", "se");Copy to clipboardErrorCopied
复制代码 isNull
isNull(field: string): RdbPredicates
配置谓词以匹配数据表的field列中值为null的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.isNull("NAME");Copy to clipboardErrorCopied
复制代码 isNotNull
isNotNull(field: string): RdbPredicates
配置谓词以匹配数据表的field列中值不为null的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.isNotNull("NAME");Copy to clipboardErrorCopied
复制代码 like
like(field: string, value: string): RdbPredicates
配置谓词以匹配数据表的field列中值类似于value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valuestring是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中值类似于"os"的字段,如"Rose"
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.like("NAME", "%os%");Copy to clipboardErrorCopied
复制代码 glob
glob(field: string, value: string): RdbPredicates
配置谓词匹配数据字段为string的指定字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valuestring是指示要与谓词匹配的值。
支持通配符,*表现0个、1个或多个数字或字符,?表现1个数字或字符。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中类型为string且值为"?h*g"的字段
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.glob("NAME", "?h*g");Copy to clipboardErrorCopied
复制代码 between
between(field: string, low: ValueType, high: ValueType): RdbPredicates
将谓词配置为匹配数据字段为ValueType且value在给定范围内的指定字段(包罗范围界限)。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。lowValueType是指示与谓词匹配的最小值。highValueType是指示要与谓词匹配的最大值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中大于等于10且小于等于50的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.between("AGE", 10, 50);Copy to clipboardErrorCopied
复制代码 notBetween
notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值超出给定范围的字段(不包罗范围界限)。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。lowValueType是指示与谓词匹配的最小值。highValueType是指示与谓词匹配的最大值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中小于10或大于50的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.notBetween("AGE", 10, 50);Copy to clipboardErrorCopied
复制代码 greaterThan
greaterThan(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值大于value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中大于18的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.greaterThan("AGE", 18);Copy to clipboardErrorCopied
复制代码 lessThan
lessThan(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值小于value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中小于20的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.lessThan("AGE", 20);Copy to clipboardErrorCopied
复制代码 greaterThanOrEqualTo
greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值大于或者等于value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中大于等于18的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.greaterThanOrEqualTo("AGE", 18);Copy to clipboardErrorCopied
复制代码 lessThanOrEqualTo
lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
配置谓词以匹配数据表的field列中值小于或者等于value的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueValueType是指示要与谓词匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中小于等于20的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.lessThanOrEqualTo("AGE", 20);Copy to clipboardErrorCopied
复制代码 orderByAsc
orderByAsc(field: string): RdbPredicates
配置谓词以匹配数据表的field列中值按升序排序的列。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.orderByAsc("NAME");Copy to clipboardErrorCopied
复制代码 orderByDesc
orderByDesc(field: string): RdbPredicates
配置谓词以匹配数据表的field列中值按降序排序的列。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.orderByDesc("AGE");Copy to clipboardErrorCopied
复制代码 distinct
distinct(): RdbPredicates
配置谓词以过滤重复记录并仅生存其中一个。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析RdbPredicates返回可用于过滤重复记录的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose").distinct();Copy to clipboardErrorCopied
复制代码 limitAs
limitAs(value: number): RdbPredicates
设置最大数据记录数的谓词。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析valuenumber是最大数据记录数。 返回值:
类型分析RdbPredicates返回可用于设置最大数据记录数的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose").limitAs(3);Copy to clipboardErrorCopied
复制代码 offsetAs
offsetAs(rowOffset: number): RdbPredicates
配置谓词以指定返回结果的起始位置。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析rowOffsetnumber是返回结果的起始位置,取值为正整数。 返回值:
类型分析RdbPredicates返回具有指定返回结果起始位置的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose").offsetAs(3);Copy to clipboardErrorCopied
复制代码 groupBy
groupBy(fields: Array<string>): RdbPredicates
配置谓词按指定列分组查询结果。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldsArray<string>是指定分组依赖的列名。 返回值:
类型分析RdbPredicates返回分组查询列的谓词。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.groupBy(["AGE", "NAME"]);Copy to clipboardErrorCopied
复制代码 indexedBy
indexedBy(field: string): RdbPredicates
配置谓词以指定索引列。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是索引列的名称。 返回值:
类型分析RdbPredicates返回具有指定索引列的RdbPredicates。 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.indexedBy("SALARY_INDEX");Copy to clipboardErrorCopied
复制代码 in
in(field: string, value: Array<ValueType>): RdbPredicates
配置谓词以匹配数据表的field列中值在给定范围内的字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueArray<ValueType>是以ValueType型数组情势指定的要匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"AGE"列中在[18,20]中的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.in("AGE", [18, 20]);Copy to clipboardErrorCopied
复制代码 notIn
notIn(field: string, value: Array<ValueType>): RdbPredicates
将谓词配置为匹配数据字段为ValueType且值超出给定范围的指定字段。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析fieldstring是数据库表中的列名。valueArray<ValueType>是以ValueType数组情势指定的要匹配的值。 返回值:
类型分析RdbPredicates返回与指定字段匹配的谓词。 示例:
- // 匹配数据表的"NAME"列中不在["Lisa", "Rose"]中的值
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.notIn("NAME", ["Lisa", "Rose"]);Copy to clipboardErrorCopied
复制代码 RdbStore
提供管理关系数据库(RDB)方法的接口。
在利用以下相关接口前,请利用executeSql接口初始化数据库表结构和相关数据。
属性10+
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析version10+number是设置和获取数据库版本,值为大于0的正整数。 示例:
- // 设置数据库版本
- if(store != undefined) {
- (store as relationalStore.RdbStore).version = 3;
- // 获取数据库版本
- console.info(`RdbStore version is ${store.version}`);
- }Copy to clipboardErrorCopied
复制代码 insert
insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void
向目标表中插入一行数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是表现要插入到表中的数据行。callbackAsyncCallback<number>是指定callback回调函数。如果操作成功,返回行ID;否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- if(store != undefined) {
- (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket, (err: BusinessError, rowId: number) => {
- if (err) {
- console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Insert is successful, rowId = ${rowId}`);
- })
- }Copy to clipboardErrorCopied
复制代码 insert10+
insert(table: string, values: ValuesBucket, conflict: ConflictResolution, callback: AsyncCallback<number>):void
向目标表中插入一行数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是表现要插入到表中的数据行。conflictConflictResolution是指定冲突解决方式。callbackAsyncCallback<number>是指定callback回调函数。如果操作成功,返回行ID;否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- if(store != undefined) {
- (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE,
- (err: BusinessError, rowId: number) => {
- if (err) {
- console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Insert is successful, rowId = ${rowId}`);
- })
- }Copy to clipboardErrorCopied
复制代码 insert
insert(table: string, values: ValuesBucket) romise<number>
向目标表中插入一行数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是表现要插入到表中的数据行。 返回值:
类型分析Promise<number>Promise对象。如果操作成功,返回行ID;否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- if(store != undefined) {
- (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket).then((rowId: number) => {
- console.info(`Insert is successful, rowId = ${rowId}`);
- }).catch((err: BusinessError) => {
- console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 insert10+
insert(table: string, values: ValuesBucket, conflict: ConflictResolution) romise<number>
向目标表中插入一行数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是表现要插入到表中的数据行。conflictConflictResolution是指定冲突解决方式。 返回值:
类型分析Promise<number>Promise对象。如果操作成功,返回行ID;否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- if(store != undefined) {
- (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((rowId: number) => {
- console.info(`Insert is successful, rowId = ${rowId}`);
- }).catch((err: BusinessError) => {
- console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 batchInsert
batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>):void
向目标表中插入一组数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesArray<ValuesBucket>是表现要插入到表中的一组数据。callbackAsyncCallback<number>是指定callback回调函数。如果操作成功,返回插入的数据个数,否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- let value5 = "Jack";
- let value6 = 19;
- let value7 = 101.5;
- let value8 = new Uint8Array([6, 7, 8, 9, 10]);
- let value9 = "Tom";
- let value10 = 20;
- let value11 = 102.5;
- let value12 = new Uint8Array([11, 12, 13, 14, 15]);
- const valueBucket1: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- const valueBucket2: ValuesBucket = {
- key1: value5,
- key2: value6,
- key3: value7,
- key4: value8,
- };
- const valueBucket3: ValuesBucket = {
- key1: value9,
- key2: value10,
- key3: value11,
- key4: value12,
- };
- let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
- if(store != undefined) {
- (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets, (err, insertNum) => {
- if (err) {
- console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
- })
- }Copy to clipboardErrorCopied
复制代码 batchInsert
batchInsert(table: string, values: Array<ValuesBucket>) romise<number>
向目标表中插入一组数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析table字符串是指定的目标表名。valuesArray<ValuesBucket>是表现要插入到表中的一组数据。 返回值:
类型分析Promise<number>Promise对象。如果操作成功,返回插入的数据个数,否则返回-1。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- let value5 = "Jack";
- let value6 = 19;
- let value7 = 101.5;
- let value8 = new Uint8Array([6, 7, 8, 9, 10]);
- let value9 = "Tom";
- let value10 = 20;
- let value11 = 102.5;
- let value12 = new Uint8Array([11, 12, 13, 14, 15]);
- const valueBucket1: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- const valueBucket2: ValuesBucket = {
- key1: value5,
- key2: value6,
- key3: value7,
- key4: value8,
- };
- const valueBucket3: ValuesBucket = {
- key1: value9,
- key2: value10,
- key3: value11,
- key4: value12,
- };
- let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
- if(store != undefined) {
- (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets).then((insertNum: number) => {
- console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
- }).catch((err: BusinessError) => {
- console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update
update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void
根据RdbPredicates的指定实例对象更新数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesRdbPredicates是RdbPredicates的实例对象指定的更新条件。回调AsyncCallback<number>是指定的callback回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update(valueBucket, predicates,(err, rows) => {
- if (err) {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Updated row count: ${rows}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update10+
update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback<number>):void
根据RdbPredicates的指定实例对象更新数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesRdbPredicates是RdbPredicates的实例对象指定的更新条件。conflictConflictResolution是指定冲突解决方式。callbackAsyncCallback<number>是指定的callback回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, (err, rows) => {
- if (err) {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Updated row count: ${rows}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update
update(values: ValuesBucket, predicates: RdbPredicates) romise<number>
根据RdbPredicates的指定实例对象更新数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesRdbPredicates是RdbPredicates的实例对象指定的更新条件。 返回值:
类型分析Promise<number>指定的Promise回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update(valueBucket, predicates).then(async (rows: Number) => {
- console.info(`Updated row count: ${rows}`);
- }).catch((err: BusinessError) => {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update10+
update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution) romise<number>
根据RdbPredicates的指定实例对象更新数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesRdbPredicates是RdbPredicates的实例对象指定的更新条件。conflictConflictResolution是指定冲突解决方式。 返回值:
类型分析Promise<number>指定的Promise回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then(async (rows: Number) => {
- console.info(`Updated row count: ${rows}`);
- }).catch((err: BusinessError) => {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update
update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void
根据DataSharePredicates的指定实例对象更新数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的更新条件。callbackAsyncCallback<number>是指定的callback回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates'
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket, predicates, (err, rows) => {
- if (err) {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Updated row count: ${rows}`);
- })
- }Copy to clipboardErrorCopied
复制代码 update
update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates) romise<number>
根据DataSharePredicates的指定实例对象更新数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。valuesValuesBucket是values指示数据库中要更新的数据行。键值对与数据库表的列名相关联。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的更新条件。 返回值:
类型分析Promise<number>指定的Promise回调方法。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- import { BusinessError } from "@ohos.base";
- let key1 = "NAME";
- let key2 = "AGE";
- let key3 = "SALARY";
- let key4 = "CODES";
- let value1 = "Rose";
- let value2 = 22;
- let value3 = 200.5;
- let value4 = new Uint8Array([1, 2, 3, 4, 5]);
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket, predicates).then(async (rows: Number) => {
- console.info(`Updated row count: ${rows}`);
- }).catch((err: BusinessError) => {
- console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 delete
delete(predicates: RdbPredicates, callback: AsyncCallback<number>):void
根据RdbPredicates的指定实例对象从数据库中删除数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析predicatesRdbPredicates是RdbPredicates的实例对象指定的删除条件。callbackAsyncCallback<number>是指定callback回调函数。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).delete(predicates, (err, rows) => {
- if (err) {
- console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Delete rows: ${rows}`);
- })
- }Copy to clipboardErrorCopied
复制代码 delete
delete(predicates: RdbPredicates) romise<number>
根据RdbPredicates的指定实例对象从数据库中删除数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析predicatesRdbPredicates是RdbPredicates的实例对象指定的删除条件。 返回值:
类型分析Promise<number>Promise对象。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).delete(predicates).then((rows: Number) => {
- console.info(`Delete rows: ${rows}`);
- }).catch((err: BusinessError) => {
- console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 delete
delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void
根据DataSharePredicates的指定实例对象从数据库中删除数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的删除条件。callbackAsyncCallback<number>是指定callback回调函数。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates, (err, rows) => {
- if (err) {
- console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`Delete rows: ${rows}`);
- })
- }Copy to clipboardErrorCopied
复制代码 delete
delete(table: string, predicates: dataSharePredicates.DataSharePredicates) romise<number>
根据DataSharePredicates的指定实例对象从数据库中删除数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的删除条件。 返回值:
类型分析Promise<number>Promise对象。返回受影响的行数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- import { BusinessError } from "@ohos.base";
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Lisa");
- if(store != undefined) {
- (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates).then((rows: Number) => {
- console.info(`Delete rows: ${rows}`);
- }).catch((err: BusinessError) => {
- console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 query10+
query(predicates: RdbPredicates, callback: AsyncCallback<ResultSet>):void
根据指定条件查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析predicatesRdbPredicates是RdbPredicates的实例对象指定的查询条件。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query(predicates, (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 query
query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void
根据指定条件查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析predicatesRdbPredicates是RdbPredicates的实例对象指定的查询条件。columnsArray<string>是表现要查询的列。如果值为空,则查询应用于所有列。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 query
query(predicates: RdbPredicates, columns?: Array<string>) romise<ResultSet>
根据指定条件查询数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析predicatesRdbPredicates是RdbPredicates的实例对象指定的查询条件。columnsArray<string>否表现要查询的列。如果值为空,则查询应用于所有列。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 返回值:
类型分析Promise<ResultSet>Promise对象。如果操作成功,则返回ResultSet对象。 示例:
- import { BusinessError } from "@ohos.base";
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- }).catch((err: BusinessError) => {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 query10+
query(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<ResultSet>):void
根据指定条件查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的查询条件。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 query
query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void
根据指定条件查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的查询条件。columnsArray<string>是表现要查询的列。如果值为空,则查询应用于所有列。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 query
query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>) romise<ResultSet>
根据指定条件查询数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
模子约束: 此接口仅可在Stage模子下可用。
体系接口: 此接口为体系接口。
参数:
参数名类型必填分析tablestring是指定的目标表名。predicatesdataSharePredicates.DataSharePredicates是DataSharePredicates的实例对象指定的查询条件。columnsArray<string>否表现要查询的列。如果值为空,则查询应用于所有列。 返回值:
类型分析Promise<ResultSet>Promise对象。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import dataSharePredicates from '@ohos.data.dataSharePredicates';
- import { BusinessError } from "@ohos.base";
- let predicates = new dataSharePredicates.DataSharePredicates();
- predicates.equalTo("NAME", "Rose");
- if(store != undefined) {
- (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- }).catch((err: BusinessError) => {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 remoteQuery
remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string> , callback: AsyncCallback<ResultSet>): void
根据指定条件查询远程装备数据库中的数据。利用callback异步回调。
分析:
其中device通过调用deviceManager.getAvailableDeviceListSync方法得到。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析devicestring是指定的远程装备ID。tablestring是指定的目标表名。predicatesRdbPredicates是RdbPredicates的实例对象,指定查询的条件。columnsArray<string>是表现要查询的列。如果值为空,则查询应用于所有列。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- import { BusinessError } from "@ohos.base";
- let dmInstance: deviceManager.DeviceManager;
- let deviceId: string | undefined = undefined;
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices = dmInstance.getAvailableDeviceListSync();
- if(deviceId != undefined) {
- deviceId = devices[0].networkId;
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message;
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
- predicates.greaterThan("id", 0);
- if(store != undefined && deviceId != undefined) {
- (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- }).catch((err: BusinessError) => {
- console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 remoteQuery
remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet>
根据指定条件查询远程装备数据库中的数据。利用Promise异步回调。
分析:
其中device通过调用deviceManager.getAvailableDeviceListSync方法得到。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析devicestring是指定的远程装备ID。tablestring是指定的目标表名。predicatesRdbPredicates是RdbPredicates的实例对象,指定查询的条件。columnsArray<string>是表现要查询的列。如果值为空,则查询应用于所有列。 返回值:
类型分析Promise<ResultSet>Promise对象。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- import { BusinessError } from "@ohos.base";
- let dmInstance: deviceManager.DeviceManager;
- let deviceId: string | undefined = undefined;
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
- if(devices != undefined) {
- deviceId = devices[0].networkId;
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message;
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
- predicates.greaterThan("id", 0);
- if(store != undefined && deviceId != undefined) {
- (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- }).catch((err: BusinessError) => {
- console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 querySql10+
querySql(sql: string, callback: AsyncCallback<ResultSet>):void
根据指定SQL语句查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'", (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 querySql
querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void
根据指定SQL语句查询数据库中的数据,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。bindArgsArray<ValueType>是SQL语句中参数的值。该值与sql参数语句中的占位符相对应。当sql参数语句完整时,该参数需为空数组。callbackAsyncCallback<ResultSet>是指定callback回调函数。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], (err, resultSet) => {
- if (err) {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- })
- }Copy to clipboardErrorCopied
复制代码 querySql
querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet>
根据指定SQL语句查询数据库中的数据,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。bindArgsArray<ValueType>否SQL语句中参数的值。该值与sql参数语句中的占位符相对应。当sql参数语句完整时,该参数不填。 返回值:
类型分析Promise<ResultSet>Promise对象。如果操作成功,则返回ResultSet对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'").then((resultSet: relationalStore.ResultSet) => {
- console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
- // resultSet是一个数据集合的游标,默认指向第-1个记录,有效的数据从0开始。
- while (resultSet.goToNextRow()) {
- const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
- const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
- const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
- const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
- console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
- }
- // 释放数据集的内存
- resultSet.close();
- }).catch((err: BusinessError) => {
- console.error(`Query failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 executeSql10+
executeSql(sql: string, callback: AsyncCallback<void>):void
实行包罗指定参数但不返回值的SQL语句,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
- if(store != undefined) {
- (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, (err) => {
- if (err) {
- console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Delete table done.');
- })
- }Copy to clipboardErrorCopied
复制代码 executeSql
executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>):void
实行包罗指定参数但不返回值的SQL语句,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。bindArgsArray<ValueType>是SQL语句中参数的值。该值与sql参数语句中的占位符相对应。当sql参数语句完整时,该参数需为空数组。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
- if(store != undefined) {
- (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, ['zhangsan'], (err) => {
- if (err) {
- console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Delete table done.');
- })
- }Copy to clipboardErrorCopied
复制代码 executeSql
executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void>
实行包罗指定参数但不返回值的SQL语句,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析sqlstring是指定要实行的SQL语句。bindArgsArray<ValueType>否SQL语句中参数的值。该值与sql参数语句中的占位符相对应。当sql参数语句完整时,该参数不填。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
- if(store != undefined) {
- (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE).then(() => {
- console.info('Delete table done.');
- }).catch((err: BusinessError) => {
- console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 getModifyTime10+
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], callback: AsyncCallback<ModifyTime>): void
获取数据库表中数据的末了修改时间,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定要查询的数据库表的表名。columnNamestring是指定要查询的数据库表的列名。primaryKeysPRIKeyType[]是指定要查询的行的主键。
如果数据库表无主键,参数columnName需传入"rowid",此时primaryKeys为要查询的数据库表的行号。
如果数据库表无主键,参数columnName传入不为"rowid",返回对应的错误码。callbackAsyncCallback<ModifyTime>是指定callback回调函数。如果操作成功,则返回ModifyTime对象,表现数据的末了修改时间。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- let PRIKey = [1, 4, 2, 3];
- if(store != undefined) {
- (store as relationalStore.RdbStore).getModifyTime("cloud_tasks", "uuid", PRIKey, (err, modifyTime: relationalStore.ModifyTime) => {
- if (err) {
- console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- let size = modifyTime.size;
- });
- }Copy to clipboardErrorCopied
复制代码 getModifyTime10+
getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Promise<ModifyTime>
获取数据库表中数据的末了修改时间,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablestring是指定要查询的数据库表的表名。columnNamestring是指定要查询的数据库表的列名。primaryKeysPRIKeyType[]是指定要查询的行的主键。
如果数据库表无主键,参数columnName需传入"rowid",此时primaryKeys为要查询的数据库表的行号。
如果数据库表无主键,参数columnName传入不为"rowid",返回对应的错误码。 返回值:
类型分析Promise<ModifyTime>返回ModifyTime类型的Promise对象,表现数据末了的修改时间。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- let PRIKey = [1, 2, 3];
- if(store != undefined) {
- (store as relationalStore.RdbStore).getModifyTime("cloud_tasks", "uuid", PRIKey)
- .then((modifyTime: relationalStore.ModifyTime) => {
- let size = modifyTime.size;
- })
- .catch((err: BusinessError) => {
- console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
- });
- }Copy to clipboardErrorCopied
复制代码 beginTransaction
beginTransaction():void
在开始实行SQL语句之前,开始事务。 此接口不支持在多历程或多线程中利用。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800047The WAL file size exceeds the default limit.14800000Inner error. 示例:
- import featureAbility from '@ohos.ability.featureAbility'
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let context = getContext(this);
- let key1 = "name";
- let key2 = "age";
- let key3 = "SALARY";
- let key4 = "blobType";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3]);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(context, STORE_CONFIG, async (err, store) => {
- if (err) {
- console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store.beginTransaction();
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- await store.insert("test", valueBucket);
- store.commit();
- })Copy to clipboardErrorCopied
复制代码 commit
commit():void
提交已实行的SQL语句。 此接口不支持在多历程或多线程中利用。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let context = getContext(this);
- let key1 = "name";
- let key2 = "age";
- let key3 = "SALARY";
- let key4 = "blobType";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3]);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(context, STORE_CONFIG, async (err, store) => {
- if (err) {
- console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- store.beginTransaction();
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- await store.insert("test", valueBucket);
- store.commit();
- })Copy to clipboardErrorCopied
复制代码 rollBack
rollBack():void
回滚已经实行的SQL语句。 此接口不支持在多历程或多线程中利用。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
示例:
- import { ValuesBucket } from '@ohos.data.ValuesBucket';
- let context = getContext(this);
- let key1 = "name";
- let key2 = "age";
- let key3 = "SALARY";
- let key4 = "blobType";
- let value1 = "Lisa";
- let value2 = 18;
- let value3 = 100.5;
- let value4 = new Uint8Array([1, 2, 3]);
- const STORE_CONFIG: relationalStore.StoreConfig = {
- name: "RdbTest.db",
- securityLevel: relationalStore.SecurityLevel.S1
- };
- relationalStore.getRdbStore(context, STORE_CONFIG, async (err, store) => {
- if (err) {
- console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- try {
- store.beginTransaction()
- const valueBucket: ValuesBucket = {
- key1: value1,
- key2: value2,
- key3: value3,
- key4: value4,
- };
- await store.insert("test", valueBucket);
- store.commit();
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Transaction failed, code is ${code},message is ${message}`);
- store.rollBack();
- }
- })Copy to clipboardErrorCopied
复制代码 backup
backup(destName:string, callback: AsyncCallback<void>):void
以指定名称备份数据库,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析destNamestring是指定命据库的备份文件名。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).backup("dbBackup.db", (err) => {
- if (err) {
- console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Backup success.');
- })
- }Copy to clipboardErrorCopied
复制代码 backup
backup(destName:string): Promise<void>
以指定名称备份数据库,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析destNamestring是指定命据库的备份文件名。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- let promiseBackup = (store as relationalStore.RdbStore).backup("dbBackup.db");
- promiseBackup.then(() => {
- console.info('Backup success.');
- }).catch((err: BusinessError) => {
- console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 restore
restore(srcName:string, callback: AsyncCallback<void>):void
从指定的数据库备份文件恢复数据库,利用callback异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析srcNamestring是指定命据库的备份文件名。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).restore("dbBackup.db", (err) => {
- if (err) {
- console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Restore success.');
- })
- }Copy to clipboardErrorCopied
复制代码 restore
restore(srcName:string): Promise<void>
从指定的数据库备份文件恢复数据库,利用Promise异步回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析srcNamestring是指定命据库的备份文件名。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- let promiseRestore = (store as relationalStore.RdbStore).restore("dbBackup.db");
- promiseRestore.then(() => {
- console.info('Restore success.');
- }).catch((err: BusinessError) => {
- console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 setDistributedTables
setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void
设置分布式数据库表,利用callback异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablesArray<string>是要设置的分布式数据库表表名。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], (err) => {
- if (err) {
- console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('SetDistributedTables successfully.');
- })
- }Copy to clipboardErrorCopied
复制代码 setDistributedTables
setDistributedTables(tables: Array<string>): Promise<void>
设置分布式数据库表,利用Promise异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablesArrayArray<string>是要设置的分布式数据库表表名。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"]).then(() => {
- console.info('SetDistributedTables successfully.');
- }).catch((err: BusinessError) => {
- console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 setDistributedTables10+
setDistributedTables(tables: Array<string>, type: DistributedType, callback: AsyncCallback<void>): void
设置分布式数据库表,利用callback异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablesArray<string>是要设置的分布式数据库表表名。typeDistributedType是表的分布式类型。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800051The type of the distributed table does not match. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, (err) => {
- if (err) {
- console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('SetDistributedTables successfully.');
- })
- }Copy to clipboardErrorCopied
复制代码
setDistributedTables10+
setDistributedTables(tables: Array<string>, type: DistributedType, config: DistributedConfig, callback: AsyncCallback<void>): void
设置分布式数据库表,利用callback异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablesArray<string>是要设置的分布式数据库表表名。typeDistributedType是表的分布式类型。configDistributedConfig是表的分布式配置信息。callbackAsyncCallback<void>是指定callback回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800051The type of the distributed table does not match. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
- autoSync: true
- }, (err) => {
- if (err) {
- console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('SetDistributedTables successfully.');
- })
- }Copy to clipboardErrorCopied
复制代码 setDistributedTables10+
setDistributedTables(tables: Array<string>, type?: DistributedType, config?: DistributedConfig): Promise<void>
设置分布式数据库表,利用Promise异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析tablesArray<string>是要设置的分布式数据库表表名。typeDistributedType否表的分布式类型。默认值是relationalStore.DistributedType.DISTRIBUTED_DEVICE。configDistributedConfig否表的分布式配置信息。不传入时默认autoSync为false,即只支持手动同步。 返回值:
类型分析Promise<void>无返回结果的Promise对象。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800051The type of the distributed table does not match. 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
- autoSync: true
- }).then(() => {
- console.info('SetDistributedTables successfully.');
- }).catch((err: BusinessError) => {
- console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 obtainDistributedTableName
obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void
根据远程装备的当地表名获取指定远程装备的分布式表名。在查询远程装备数据库时,需要利用分布式表名, 利用callback异步回调。
分析:
其中device通过调用deviceManager.getAvailableDeviceListSync方法得到。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析device字符串是远程装备ID 。table字符串是远程装备的当地表名。回调AsyncCallback<string>是指定的callback回调函数。如果操作成功,返回远程装备的分布式表名。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- let dmInstance: deviceManager.DeviceManager;
- let deviceId: string | undefined = undefined;
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices = dmInstance.getAvailableDeviceListSync();
- deviceId = devices[0].networkId;
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- if(store != undefined && deviceId != undefined) {
- (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
- if (err) {
- console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
- })
- }复制到剪贴板错误复制
复制代码 obtainDistributedTableName
obtainDistributedTableName(device: string, table: string): Promise<string>
根据远程装备的当地表名获取指定远程装备的分布式表名。在查询远程装备数据库时,需要利用分布式表名,利用Promise异步回调。
分析:
其中device通过调用deviceManager.getAvailableDeviceListSync方法得到。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析device字符串是远程装备ID。table字符串是远程装备的当地表名。 返回值:
类型分析Promise<string>Promise对象。如果操作成功,返回远程装备的分布式表名。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- import { BusinessError } from "@ohos.base";
- let dmInstance: deviceManager.DeviceManager;
- let deviceId: string | undefined = undefined;
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices = dmInstance.getAvailableDeviceListSync();
- deviceId = devices[0].networkId;
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- if(store != undefined && deviceId != undefined) {
- (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE").then((tableName: string) => {
- console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
- }).catch((err: BusinessError) => {
- console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
- })
- }复制到剪贴板错误复制
复制代码 sync
sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void
在装备之间同步数据, 利用callback异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析modeSyncMode是指同步模式。该值可以是relationalStore.SyncMode.SYNC_MODE_PUSH、relationalStore.SyncMode.SYNC_MODE_PULL。predicatesRdbPredicates是约束同步数据和装备。callbackAsyncCallback<Array<[string, number]>>是指定的callback回调函数,用于向调用者发送同步结果。string:装备ID;number:每个装备同步状态,0表现成功,其他值表现失败。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- let dmInstance: deviceManager.DeviceManager;
- let deviceIds: Array<string> = [];
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
- for (let i = 0; i < devices.length; i++) {
- deviceIds[i] = devices[i].networkId!;
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
- predicates.inDevices(deviceIds);
- if(store != undefined) {
- (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) => {
- if (err) {
- console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Sync done.');
- for (let i = 0; i < result.length; i++) {
- console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
- }
- })
- }Copy to clipboardErrorCopied
复制代码 sync
sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>>
在装备之间同步数据,利用Promise异步回调。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析modeSyncMode是指同步模式。该值可以是relationalStore.SyncMode.SYNC_MODE_PUSH、relationalStore.SyncMode.SYNC_MODE_PULL。predicatesRdbPredicates是约束同步数据和装备。 返回值:
类型分析Promise<Array<[string, number]>>Promise对象,用于向调用者发送同步结果。string:装备ID;number:每个装备同步状态,0表现成功,其他值表现失败。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error. 示例:
- import deviceManager from '@ohos.distributedDeviceManager';
- import { BusinessError } from "@ohos.base";
- let dmInstance: deviceManager.DeviceManager;
- let deviceIds: Array<string> = [];
- try {
- dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
- let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
- for (let i = 0; i < devices.length; i++) {
- deviceIds[i] = devices[i].networkId!;
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
- }
- let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
- predicates.inDevices(deviceIds);
- if(store != undefined) {
- (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates).then((result: Object[][]) => {
- console.info('Sync done.');
- for (let i = 0; i < result.length; i++) {
- console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
- }
- }).catch((err: BusinessError) => {
- console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
- })
- }Copy to clipboardErrorCopied
复制代码 cloudSync10+
cloudSync(mode: SyncMode, progress: Callback< rogressDetails>, callback: AsyncCallback<void>): void
手动实行对所有分布式表的端云同步,利用callback异步回调。利用该接口需要实现云服务功能。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client
参数:
参数名类型必填分析模式SyncMode是表现数据库的同步模式。progressCallback< rogressDetails>是用来处理数据库同步具体信息的回调函数。回调AsyncCallback<void>是指定的callback回调函数,用于向调用者发送同步结果。 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetails) => {
- console.info(`Progess: ${progressDetails}`);
- }, (err) => {
- if (err) {
- console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Cloud sync succeeded');
- });
- }复制到剪贴板错误复制
复制代码 cloudSync10+
cloudSync(mode: SyncMode, progress: Callback< rogressDetails>): Promise<void>
手动实行对所有分布式表的端云同步,利用Promise异步回调。利用该接口需要实现云服务功能。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client
参数:
参数名类型必填分析模式SyncMode是表现数据库的同步模式。progressCallback< rogressDetails>是用来处理数据库同步具体信息的回调函数。 返回值:
类型分析承诺<无效>Promise对象,用于向调用者发送同步结果。 示例:
- import { BusinessError } from "@ohos.base";
- if(store != undefined) {
- (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
- console.info(`progress: ${progressDetail}`);
- }).then(() => {
- console.info('Cloud sync succeeded');
- }).catch((err: BusinessError) => {
- console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
- });
- }复制到剪贴板错误复制
复制代码 cloudSync10+
cloudSync(mode: SyncMode, tables: string[], progress: Callback< rogressDetails>, callback: AsyncCallback<void>): void
手动实行对指定表的端云同步,利用callback异步回调。利用该接口需要实现云服务功能。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client
参数:
参数名类型必填分析模式SyncMode是表现数据库的同步模式。tablesstring[]是指定同步的表名。progressCallback< rogressDetails>是用来处理数据库同步具体信息的回调函数。回调AsyncCallback<void>是指定的callback回调函数,用于向调用者发送同步结果。 示例:
- const tables = ["table1", "table2"];
- if(store != undefined) {
- (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
- console.info(`Progess: ${progressDetail}`);
- }, (err) => {
- if (err) {
- console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
- return;
- }
- console.info('Cloud sync succeeded');
- });
- };Copy to clipboardErrorCopied
复制代码 cloudSync10+
cloudSync(mode: SyncMode, tables: string[], progress: Callback< rogressDetails>): Promise<void>
手动实行对指定表的端云同步,利用Promise异步回调。利用该接口需要实现云服务功能。
需要权限: ohos.permission.DISTRIBUTED_DATASYNC
体系能力: SystemCapability.DistributedDataManager.CloudSync.Client
参数:
参数名类型必填分析modeSyncMode是表现数据库的同步模式。tablesstring[]是指定同步的表名。progressCallback< rogressDetails>是用来处理数据库同步具体信息的回调函数。 返回值:
类型分析Promise<void>Promise对象,用于向调用者发送同步结果。 示例:
- import { BusinessError } from "@ohos.base";
- const tables = ["table1", "table2"];
- if(store != undefined) {
- (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
- console.info(`progress: ${progressDetail}`);
- }).then(() => {
- console.info('Cloud sync succeeded');
- }).catch((err: BusinessError) => {
- console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
- });
- };Copy to clipboardErrorCopied
复制代码 on('dataChange')
on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void
注册数据库的数据变更的事故监听。当分布式数据库中的数据发生更改时,将调用回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析eventstring是取值为'dataChange',表现数据更改。typeSubscribeType是订阅类型。observerCallback<Array<string>>是指分布式数据库中数据更改事故的观察者。Array<string>为数据库中的数据发生改变的对端装备ID。 示例:
- import deviceManager from '@ohos.distributedHardware.deviceManager';
- let devices: string | undefined = undefined;
- try {
- if (store != undefined) {
- (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
- if (devices != undefined) {
- for (let i = 0; i < devices.length; i++) {
- console.info(`device= ${devices[i]} data changed`);
- }
- }
- })
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Register observer failed, code is ${code},message is ${message}`);
- }Copy to clipboardErrorCopied
复制代码 on('dataChange')10+
on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>| Callback<Array<ChangeInfo>>): void
注册数据库的数据变更的事故监听。当分布式数据库中的数据发生更改时,将调用回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析eventstring是取值为'dataChange',表现数据更改。typeSubscribeType是订阅类型。observerCallback<Array<string>> | Callback<Array<ChangeInfo>>是回调函数。
当type为SUBSCRIBE_TYPE_REMOTE,observer类型需为Callback<Array<string>>,其中Array<string>为数据库中的数据发生改变的对端装备ID。
当type为SUBSCRIBE_TYPE_CLOUD,observer类型需为Callback<Array<string>>,其中Array<string>为数据库中的数据发生改变的云端帐号。
当type为SUBSCRIBE_TYPE_CLOUD_DETAILS,observer类型需为Callback<Array<ChangeInfo>>,其中Array<ChangeInfo>为数据库端云同步过程的详情。 示例:
- import deviceManager from '@ohos.distributedHardware.deviceManager';
- let devices: string | undefined = undefined;
- try {
- if(store != undefined) {
- (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver => {
- if (devices != undefined) {
- for (let i = 0; i < devices.length; i++) {
- console.info(`device= ${devices[i]} data changed`);
- }
- }
- });
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Register observer failed, code is ${code},message is ${message}`);
- }复制到剪贴板错误复制
复制代码 on10+
on(event: string, interProcess: boolean, observer: Callback<void>): void
注册数据库的历程内或者历程间事故监听。当调用emit接口时,将调用回调。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析事故字符串是订阅事故名称。interProcess布尔是指定是历程间照旧本历程订阅。
true:历程间。
false:本历程。observerCallback<void>是回调函数。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800050Failed to obtain subscription service. 示例:
- try {
- if(store != undefined) {
- (store as relationalStore.RdbStore).on('storeObserver', false, (storeObserver) => {
- console.info(`storeObserver`);
- });
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Register observer failed, code is ${code},message is ${message}`);
- }复制到剪贴板错误复制
复制代码 off('dataChange')
off(event:'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void
取消数据变更的事故监听。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析事故字符串是取值为'dataChange',表现数据更改。类型SubscribeType是订阅类型。observerCallback<Array<string>>是指已注册的数据更改观察者。Array<string>为数据库中的数据发生改变的对端装备ID。 示例:
- let devices: string | undefined = undefined;
- try {
- if(store != undefined) {
- (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
- if (devices != undefined){
- for (let i = 0; i < devices.length; i++) {
- console.info(`device= ${devices[i]} data changed`);
- }
- }
- });
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Unregister observer failed, code is ${code},message is ${message}`);
- }复制到剪贴板错误复制
复制代码 off('dataChange')10+
off(event:'dataChange', type: SubscribeType, observer?: Callback<Array<string>>| Callback<Array<ChangeInfo>>): void
取消数据变更的事故监听。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析eventstring是取值为'dataChange',表现数据更改。typeSubscribeType是订阅类型。observerCallback<Array<string>>| Callback<Array<ChangeInfo>>否回调函数。
当type为SUBSCRIBE_TYPE_REMOTE,observer类型需为Callback<Array<string>>,其中Array<string>为数据库中的数据发生改变的对端装备ID。
当type为SUBSCRIBE_TYPE_CLOUD,observer类型需为Callback<Array<string>>,其中Array<string>为数据库中的数据发生改变的云端帐号。
当type为SUBSCRIBE_TYPE_CLOUD_DETAILS,observer类型需为Callback<Array<ChangeInfo>>,其中Array<ChangeInfo>为数据库端云同步过程的详情。
当observer没有传入时,表现取消当前type类型下所有数据变更的事故监听。 示例:
- import deviceManager from '@ohos.distributedHardware.deviceManager';
- let devices: string | undefined = undefined;
- try {
- if(store != undefined) {
- (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
- if (devices != undefined) {
- for (let i = 0; i < devices.length; i++) {
- console.info(`device= ${devices[i]} data changed`);
- }
- }
- });
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Unregister observer failed, code is ${code},message is ${message}`);
- }Copy to clipboardErrorCopied
复制代码 off10+
off(event: string, interProcess: boolean, observer?: Callback<void>): void
取消数据变更的事故监听。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析eventstring是取消订阅事故名称。interProcessboolean是指定是历程间照旧本历程取消订阅。
true:历程间。
false:本历程。observerCallback<void>否该参数存在,则取消指定Callback监听回调,否则取消该event事故的所有监听回调。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800050Failed to obtain subscription service. 示例:
- try {
- if(store != undefined) {
- (store as relationalStore.RdbStore).off('storeObserver', false, (storeObserver) => {
- console.info(`storeObserver`);
- });
- }
- } catch (err) {
- let code = (err as BusinessError).code;
- let message = (err as BusinessError).message
- console.error(`Register observer failed, code is ${code},message is ${message}`);
- }Copy to clipboardErrorCopied
复制代码 emit10+
emit(event: string): void
关照通过on注册的历程间或者历程内监听事故。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析eventstring是关照订阅事故的名称。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800000Inner error.14800050Failed to obtain subscription service. 示例:
- if(store != undefined) {
- (store as relationalStore.RdbStore).emit('storeObserver');
- }Copy to clipboardErrorCopied
复制代码 ResultSet
提供通过查询数据库生成的数据库结果集的访问方法。结果集是指用户调用关系型数据库查询接口之后返回的结果集合,提供了多种机动的数据访问方式,以便用户获取各项数据。
利用分析
起首需要获取resultSet对象。
示例:
- let resultSet: relationalStore.ResultSet | undefined = undefined;
- let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
- predicates.equalTo("AGE", 18);
- if(store != undefined) {
- (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((result: relationalStore.ResultSet) => {
- resultSet = result;
- console.info(`resultSet columnNames: ${resultSet.columnNames}`);
- console.info(`resultSet columnCount: ${resultSet.columnCount}`);
- });
- }Copy to clipboardErrorCopied
复制代码 属性
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
名称类型必填分析columnNamesArray<string>是获取结果会集所有列的名称。columnCountnumber是获取结果会集的列数。rowCountnumber是获取结果会集的行数。rowIndexnumber是获取结果集当前行的索引。isAtFirstRowboolean是检查结果集是否位于第一行。isAtLastRowboolean是检查结果集是否位于末了一行。isEndedboolean是检查结果集是否位于末了一行之后。isStartedboolean是检查指针是否移动过。isClosedboolean是检查当前结果集是否关闭。 getColumnIndex
getColumnIndex(columnName: string): number
根据指定的列名获取列索引。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnNamestring是表现结果会集指定列的名称。 返回值:
类型分析number返回指定列的索引。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const id = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("ID"));
- const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
- const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
- const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
- }Copy to clipboardErrorCopied
复制代码 getColumnName
getColumnName(columnIndex: number): string
根据指定的列索引获取列名。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是表现结果会集指定列的索引。 返回值:
类型分析字符串返回指定列的名称。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const id = (resultSet as relationalStore.ResultSet).getColumnName(0);
- const name = (resultSet as relationalStore.ResultSet).getColumnName(1);
- const age = (resultSet as relationalStore.ResultSet).getColumnName(2);
- }复制到剪贴板错误复制
复制代码 goTo
goTo(offset:number): boolean
向前或向后转至结果集的指定行,相对于其当前位置偏移。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析抵消数是表现相对于当前位置的偏移量。 返回值:
类型分析布尔如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goTo(1);
- }复制到剪贴板错误复制
复制代码 goToRow
goToRow(position: number): boolean
转到结果集的指定行。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析position数是表现要移动到的指定位置。 返回值:
类型分析布尔如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goToRow(5);
- }复制到剪贴板错误复制
复制代码 goToFirstRow
goToFirstRow(): boolean
转到结果集的第一行。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析boolean如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goToFirstRow();
- }Copy to clipboardErrorCopied
复制代码 goToLastRow
goToLastRow(): boolean
转到结果集的末了一行。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析boolean如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goToLastRow();
- }Copy to clipboardErrorCopied
复制代码 goToNextRow
goToNextRow(): boolean
转到结果集的下一行。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析boolean如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goToNextRow();
- }Copy to clipboardErrorCopied
复制代码 goToPreviousRow
goToPreviousRow(): boolean
转到结果集的上一行。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
返回值:
类型分析boolean如果成功移动结果集,则为true;否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).goToPreviousRow();
- }Copy to clipboardErrorCopied
复制代码 getBlob
getBlob(columnIndex: number): Uint8Array
以字节数组的情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析Uint8Array以字节数组的情势返回指定列的值。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const codes = (resultSet as relationalStore.ResultSet).getBlob((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
- }Copy to clipboardErrorCopied
复制代码 getString
getString(columnIndex: number): string
以字符串情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析string以字符串情势返回指定列的值。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
- }Copy to clipboardErrorCopied
复制代码 getLong
getLong(columnIndex: number): number
以Long情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析number以Long情势返回指定列的值。
该接口支持的数据范围是:Number.MIN_SAFE_INTEGER ~ Number.MAX_SAFE_INTEGER,若超出该范围,发起利用getDouble。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
- }Copy to clipboardErrorCopied
复制代码 getDouble
getDouble(columnIndex: number): number
以double情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析number以double情势返回指定列的值。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
- }Copy to clipboardErrorCopied
复制代码 getAsset10+
getAsset(columnIndex: number): Asset
以Asset情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析Asset以Asset情势返回指定列的值。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const doc = (resultSet as relationalStore.ResultSet).getAsset((resultSet as relationalStore.ResultSet).getColumnIndex("DOC"));
- }Copy to clipboardErrorCopied
复制代码 getAssets10+
getAssets(columnIndex: number): Assets
以Assets情势获取当前行中指定列的值。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析Assets以Assets情势返回指定列的值。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const docs = (resultSet as relationalStore.ResultSet).getAssets((resultSet as relationalStore.ResultSet).getColumnIndex("DOCS"));
- }Copy to clipboardErrorCopied
复制代码 isColumnNull
isColumnNull(columnIndex: number): boolean
检查当前行中指定列的值是否为null。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
参数:
参数名类型必填分析columnIndexnumber是指定的列索引,从0开始。 返回值:
类型分析boolean如果当前行中指定列的值为null,则返回true,否则返回false。 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800013The column value is null or the column type is incompatible. 示例:
- if(resultSet != undefined) {
- const isColumnNull = (resultSet as relationalStore.ResultSet).isColumnNull((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
- }Copy to clipboardErrorCopied
复制代码 close
close(): void
关闭结果集。
体系能力: SystemCapability.DistributedDataManager.RelationalStore.Core
示例:
- if(resultSet != undefined) {
- (resultSet as relationalStore.ResultSet).close();
- }复制到剪贴板错误复制
复制代码 错误码:
以下错误码的具体介绍请拜见关系型数据库错误码。
错误码ID错误信息14800012The result set is empty or the specified location is invalid. 末了
有很多小同伴不知道学习哪些鸿蒙开发技能?不知道需要重点把握哪些鸿蒙应用开发知识点?而且学习时频繁踩坑,最终浪费大量时间。所以有一份实用的鸿蒙(HarmonyOS NEXT)资料用来跟着学习是非常有须要的。
这份鸿蒙(HarmonyOS NEXT)资料包罗了鸿蒙开发必把握的核心知识要点,内容包罗了(ArkTS、ArkUI开发组件、Stage模子、多端部署、分布式应用开发、音频、视频、WebGL、OpenHarmony多媒体技能、Napi组件、OpenHarmony内核、Harmony南向开发、鸿蒙项目实战等等)鸿蒙(HarmonyOS NEXT)技能知识点。
希望这一份鸿蒙学习资料能够给大家带来帮助,有需要的小同伴自行领取,限时开源,先到先得~无套路领取!!
获取这份完整版高清学习门路,请点击→纯血版全套鸿蒙HarmonyOS学习资料
鸿蒙(HarmonyOS NEXT)最新学习门路
- HarmonOS就业必备技能
- HarmonOS多媒体技能
有了门路图,怎么能没有学习资料呢,小编也预备了一份联合鸿蒙官方发布条记整理收纳的一套体系性的鸿蒙(OpenHarmony )学习手册(共计1236页)与鸿蒙(OpenHarmony )开发入门教学视频,内容包罗:ArkTS、ArkUI、Web开发、应用模子、资源分类…等知识点。
获取以上完整版高清学习门路,请点击→纯血版全套鸿蒙HarmonyOS学习资料
《鸿蒙 (OpenHarmony)开发入门教学视频》
《鸿蒙生态应用开发V2.0白皮书》
《鸿蒙 (OpenHarmony)开发基础到实战手册》
OpenHarmony北向、南向开发环境搭建
《鸿蒙开发基础》
- ArkTS语言
- 安装DevEco Studio
- 运用你的第一个ArkTS应用
- ArkUI声明式UI开发
- .……
《鸿蒙开发进阶》
- Stage模子入门
- 网络管理
- 数据管理
- 电话服务
- 分布式应用开发
- 关照与窗口管理
- 多媒体技能
- 安全技能
- 使命管理
- WebGL
- 国际化开发
- 应用测试
- DFX面向将来设计
- 鸿蒙体系移植和裁剪定制
- ……
《鸿蒙进阶实战》
- ArkTS实践
- UIAbility应用
- 网络案例
- ……
获取以上完整鸿蒙HarmonyOS学习资料,请点击→纯血版全套鸿蒙HarmonyOS学习资料
总结
总的来说,华为鸿蒙不再兼容安卓,对中年步调员来说是一个挑战,也是一个时机。只有积极应对变化,不停学习和提升本身,他们才能在这个变革的期间中立于不败之地。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |