'Can you run a custom script that affects SQLite storage in react-native

I am creating an app that will save data on the local phone memory with react-native-sqlite-storage.

I want to make a script that will create a database (if it does not exist), create the necessary tables, and then populate those tables with mock data (basically, a seed script). I plan on adding a script to my package.json to seed this data, something like

{
    ....
    "scripts": {
        ....
        "seed": "ts-node index.ts"
    }
}

Where index.ts will contain the necessary seeding script, something like:

// import react-native-sqlite-storage
const seedDatabase = () => {
    // Populate the data ...
}
seedDatabase();

But I am uncertain if this would work. Will it work? If not, is there a way to seed data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source