Cap-go/capacitor-data-storage-sqlite

setTable not setting table sometime.

dhwalin opened this issue · 3 comments

I am using following code for save the data to first table and then set second table and insert new data into it. But a thing happen is Key and Value of second table is getting overwrite in first table. So I guess table 2 is not getting changed. Please let me know if I am making some mistake.

const storage = new StorageAPIWrapper();

      let result: boolean = await storage.openStore({database:"pfmaster",table:"profiles"});

      console.log("ProfleStore",result);
      
      if(result)
      {

        await storage.setItem(
          profile_insert_id,
          JSON.stringify({
            id: profile_insert_id,
            profileImg: profileImgURL,
            firstName: firstName,
            lastName: lastName,
            text1: text1,
            text2: text2,
            text3: text3,
            text4: text4,
            fb: fb,
            ins: ins,
            tw: tw,
            wa: wa
          })
        )

        const profileImageDataTable = await storage.setTable({table:"profilesImages"});

        console.log("ProfleImageTable",profileImageDataTable);

        if(profileImageDataTable[0])
        {

          await storage.setItem(profile_insert_id,profileImg);

          setProfileId(profile_insert_id);
          setChkSaveProfile(true);

        }

      }

profileImg is base64 image value. profileImgURL is image path.

So I want to save profileImgURL in first table, then set second table and use same key and want to save profileImg base64 data.

@dhwalin Is it with Electron platform ?

@dhwalin This is fixed in release 2.4.2-2 of the capacitor-data-storage-sqlite plugin. The https://github.com/jepiqueau/react-datastoragesqlite-app has been updated (version 1.0.3) to show an example of that fix. Thanks for contributing to the debugging process. Enjoy

Thank you it works. Thank you for fixing.