1# DataAbilityResult 2 3定义dataAbility数据操作结果,通过[executeBatch](js-apis-inner-ability-dataAbilityHelper.md#dataabilityhelperexecutebatch)查询数据库信息时查询结果通过DataAbilityResult对象返回。 4 5> **说明:** 6> 7> 本接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> 本接口仅可在FA模型下使用 9 10## 导入模块 11 12```ts 13import ability from '@ohos.ability.ability'; 14``` 15 16**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel 17 18| 名称 | 类型 | 必填 | 说明 | 19| -------- | -------- | -------- | -------- | 20| uri? | string | 否 | 指定待处理的DataAbility。例:'dataability:///com.example.xxx.xxxx'。 | 21| count? | number | 否 | 指示受操作影响的行数。 | 22 23**示例:** 24 25```ts 26import featureAbility from '@ohos.ability.featureAbility'; 27 28// 批量执行数据库操作 29function executeBatchOperation() { 30 let dataAbilityUri = ('dataability:///com.example.myapplication.TestDataAbility'); 31 let DAHelper: ability.DataAbilityHelper; 32 try { 33 DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); 34 if (DAHelper === null) { 35 console.error('DAHelper is null'); 36 } 37 } catch (err) { 38 console.error('acquireDataAbilityHelper fail, error: ${JSON.stringify(err)}'); 39 } 40 41 let valueBucket = { 42 'name': 'DataAbilityHelperTest', 43 'age': 24, 44 'salary': 2024.20, 45 }; 46 let operations = [ 47 { 48 uri: dataAbilityUri, 49 type: featureAbility.DataAbilityOperationType.TYPE_INSERT, 50 valuesBucket: valueBucket, 51 predicates: null, 52 expectedCount: 1, 53 PredicatesBackReferences: {}, 54 interrupted: true, 55 }, 56 { 57 uri: dataAbilityUri, 58 type: featureAbility.DataAbilityOperationType.TYPE_INSERT, 59 valuesBucket: valueBucket, 60 predicates: null, 61 expectedCount: 1, 62 PredicatesBackReferences: {}, 63 interrupted: true, 64 } 65 ]; 66 67 try { 68 DAHelper.executeBatch(dataAbilityUri, operations).then((data) => { 69 for (let i = 0; i < data.length; i++) { 70 let dataAbilityResult: ability.DataAbilityResult = data[i]; 71 console.log('dataAbilityResult.uri: ${dataAbilityResult.uri}'); 72 console.log('dataAbilityResult.count: ${dataAbilityResult.count}'); 73 } 74 }).catch(err => { 75 console.error('executeBatch error: ${JSON.stringify(err)}'); 76 }); 77 } catch (err) { 78 console.error('executeBatch error: ${JSON.stringify(err)}'); 79 } 80} 81```