中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
关系型数据库如何删除数据?
微信扫码分享
import { ValuesBucket } from '@ohos.data.ValuesBucket'; import { relationalStore } from '@kit.ArkData'; import { BusinessError } from '@kit.BasicServicesKit'; let store: relationalStore.RdbStore | undefined = undefined; @Entry @Component struct Index { build() { Column() { Button("delete").onClick(() => { const valueBucket: ValuesBucket = { NAME:"TOM", AGE: 12, SALARY: 100.5, CODES: new Uint8Array([1, 2, 3, 4, 5]), }; //获取store步骤省略 // 删除数据 let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.equalTo('NAME', 'Lisa'); if (store !== undefined) { (store as relationalStore.RdbStore).delete(predicates, (err: BusinessError, rows: number) => { if (err) { console.error(`Failed to delete data. Code:${err.code}, message:${err.message}`); return; } console.info(`Delete rows: ${rows}`); }) } }) } .width('100%') .height('100%') .justifyContent(FlexAlign.Center) } }