Import Dexie Version From Another Page



  • I am building a mutli-page Quasar application and I’m using Dexie. I seem to have to initialize the database and the version on every page.

    Is there a way to create a .vue file that has the DB connection and version information, and import it into every page? Having to go through every page to update the version of the db is not going to work for me. I plan on having quite a few pages to keep everything organized. I don’t really understand what is needed for importing a page.

    This is my script to connect to Dexie:

    import Dexie from 'dexie';
    var pawTapDB = new Dexie('pawTapDB')
    pawTapDB.version(1.5).stores({
            peopleTable: '++p_key,l_name,p_email',
            tableHoldPersonID: '++thpid_key',
            dogTable: '++p_dog,callName'
        })
    


  • @cynderkromi do it in a boot file, this example should help you get an idea https://quasar.dev/quasar-cli/boot-files#Accessing-data-from-boot-files.



  • @metalsadman Thanks I will check that out.



  • @metalsadman I tried the boot file, but when I try to run my project, it doesn’t like my call to Dexie in the boot file.
    Really wish I could just include the file into all my other files.

    alt text



  • I figured it out.

    I am including my Dexie connect file as a .js file

    import pawTapDB from '../components/DexieConnect.js'
    
    

    and this is my DexieConnect.js file, if anyone else has this issue:

    import Dexie from 'dexie'
    const pawTapDB = new Dexie('pawTapDB')
    
    pawTapDB.version(20).stores({
        peopleTable: '++p_key,l_name,p_email',
        tableHoldPersonID: '++thpid_key',
        dogTable: '++p_dog,callName',
        tableHoldDogID: '++thdid_key',
        locationTable: '++pk_location, locationName',
        clubTable: '++pk_club'
    })
    
    export default pawTapDB
    

Log in to reply