d3x0r / gun-db

sqlite storage adapter for Gun database (javascript)
44 stars 3 forks source link

*.db file is empty, tables empty #5

Open tzvsi opened 4 years ago

tzvsi commented 4 years ago

Hi. I'm getting an empty SQLite file and empty tables when running default config and/or sack.vfs. Appears the data is in memory, but not writing to SQLite file.. the *.db file doesn't appear to write to disk after put events. When should this persist to disk?

Example:

var vfs = require( "sack.vfs")
var vol = vfs.Volume( "MountName", "vfsFile.dat" )

var gun = Gun({
    file: false,
    db: {
        file: "s1.db",
        exclusive : false
    },
    peers: peers
})

var data = gun.get('data').put({name: 'xyz', age: 41});
var data = gun.get('data').on((val, field)=>{console.log( field,' = ', val );setTimeout( dumpDatabase, 100 )})

function dumpDatabase() {
    var db = vol.Sqlite("s1.db")
    var tables = db.do( "select tbl_name from sqlite_master where type='table'" );
    console.log( "Tables:", tables );
    if (tables.length > 0) {
        var records = db.do("select * from record");
        console.log("records:");
        records.forEach(rec => {
            console.log(`s:${rec.soul} f:${rec.field} v:${rec.value} r:${rec.relation} s:${rec.state}`);
        });
    }
}

Env:

d3x0r commented 4 years ago

I will look into this; perhaps an internal of Gun change. It should persist on the disk almost immediately.

d3x0r commented 4 years ago

Hmm, I had some issues getting visual studio 17 to work again (I had uninstalled it end of last year); finally was able to update to the latest gun (2020.301) and, it seems the writes are stalled for some reason; so actually nothing ends up getting any data back in either. Will look into this in a bit; have a few other projects that are going to distract me first.

tzvsi commented 4 years ago

Ok, thanks for looking into this. Glad you replicated the issue. Will be on standby..

On Mon, Mar 23, 2020 at 8:42 AM Jim B notifications@github.com wrote:

Hmm, I had some issues getting visual studio 17 to work again (I had uninstalled it end of last year); finally was able to update to the latest gun (2020.301) and, it seems the writes are stalled for some reason; so actually nothing ends up getting any data back in either. Will look into this in a bit; have a few other projects that are going to distract me first.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/d3x0r/gun-db/issues/5#issuecomment-602682371, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHANR2BBUWH2OQVOVRKARCTRI57MPANCNFSM4LQ7WLKQ .