Kaynağa Gözat

新增mapper维护单表数据

chenritian 1 ay önce
ebeveyn
işleme
f23198c9dc

+ 7 - 7
features/feature/src/main/ets/view/ThirdView.ets

@@ -4,7 +4,7 @@ import { Pet, RDBMapper, RelationalStoreUtils, Test } from "basic";
 export struct ThirdView {
   @State list: Test[] = []
   @State list2: Pet[] = []
-  testMapper:RDBMapper<Pet> = new RDBMapper(Pet)
+  petMapper:RDBMapper<Pet> = new RDBMapper(Pet)
   build() {
     Column() {
       Row() {
@@ -47,9 +47,9 @@ export struct ThirdView {
       Row() {
         Button('测试新增2')
           .onClick(() => {
-            this.testMapper.insert( { name: 'test1', tag: '标签' }, () => {
+            this.petMapper.insert( { name: 'test1', tag: '标签' }, () => {
               console.log('insert success');
-              let list = this.testMapper.getListSync()
+              let list = this.petMapper.getListSync()
               this.list2 = list
               console.log('list:', JSON.stringify(list))
             })
@@ -57,18 +57,18 @@ export struct ThirdView {
 
         Button('测试修改2')
           .onClick(() => {
-            this.testMapper.updateItemById({ id: 1, name: '测试1修改',tag: '标签2' }, () => {
+            this.petMapper.updateItemById({ id: 1, name: '测试1修改',tag: '标签2' }, () => {
               console.log('insert success');
-              let list = this.testMapper.getListSync()
+              let list = this.petMapper.getListSync()
               this.list2= list
               console.log('list:', JSON.stringify(list))
             })
           })
         Button('测试删除2')
           .onClick(() => {
-            this.testMapper.deleteItemByIdSync(1)
+            this.petMapper.deleteItemByIdSync(1)
             console.log('insert success');
-            let list = this.testMapper.getListSync()
+            let list = this.petMapper.getListSync()
             this.list2 = list
             console.log('list:', JSON.stringify(list))
           })