gun-db icon indicating copy to clipboard operation
gun-db copied to clipboard

*.db file is empty, tables empty

Open tzvsi opened this issue 5 years ago • 3 comments

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:

  • node v13.8.0
  • gun v0.2020.301
  • gun-db v1.0.571

tzvsi avatar Mar 21 '20 17:03 tzvsi

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

d3x0r avatar Mar 22 '20 01:03 d3x0r

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.

d3x0r avatar Mar 23 '20 15:03 d3x0r

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 [email protected] 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 .

tzvsi avatar Mar 23 '20 18:03 tzvsi