OP-Engineering / op-sqlite

Fastest SQLite library for react-native by @ospfranco
MIT License
603 stars 40 forks source link

[ios] moveAssetsDatabase | Add support for path #99

Closed marqroldan closed 6 months ago

marqroldan commented 6 months ago

We have a case where we use .bundle to "load" all the files in the folder; we utilize IOSConfig.XcodeUtils.addResourceFileToGroup to do this

And at the moment it's done the same way with Android as well, using android.sourceSets

Basically the tree is

at `./`
        -> db.bundle/
                - main.db
                - exec.sql

I tried to prefix the filename with the bundle name but it unfortunately didn't work. Tinkered around a bit and found this to work.

The following change allows us to have the same code on JS and actually be able to access the file.

    const moved = await moveAssetsDatabase({
      filename: 'main.db',
      path: 'db.bundle',
    });

I'm not that knowledgeable with Swift/Objective-C so I am not sure if this is the optimal way to do it

ospfranco commented 6 months ago

I explicitly do not want to do this because the semantics get complicated. In android when using the link assets command it will land in /custom/db.bundle/main.db. It gets complicated and confusing and will require more documentation and me closing tickets in the future explaining how to call the move db and open function correctly over and over.

I think for you use case is better to call the moveDatabases function first and then using another FS package to move it to the final path you want.