{"id":24555045,"url":"https://github.com/d3x0r/gun-db","last_synced_at":"2025-04-16T03:18:05.804Z","repository":{"id":57259690,"uuid":"88878843","full_name":"d3x0r/gun-db","owner":"d3x0r","description":"sqlite storage adapter for Gun database (javascript)","archived":false,"fork":false,"pushed_at":"2019-06-07T12:47:29.000Z","size":34,"stargazers_count":46,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-16T03:17:49.204Z","etag":null,"topics":["gun","odbc","sql","sqlite-database","storage-driver"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d3x0r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-20T15:03:34.000Z","updated_at":"2024-12-06T05:32:20.000Z","dependencies_parsed_at":"2022-08-24T22:04:20.449Z","dependency_job_id":null,"html_url":"https://github.com/d3x0r/gun-db","commit_stats":null,"previous_names":["d3x0r/gun.db"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3x0r%2Fgun-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3x0r%2Fgun-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3x0r%2Fgun-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3x0r%2Fgun-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d3x0r","download_url":"https://codeload.github.com/d3x0r/gun-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249188432,"owners_count":21227015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gun","odbc","sql","sqlite-database","storage-driver"],"created_at":"2025-01-23T03:37:55.954Z","updated_at":"2025-04-16T03:18:05.785Z","avatar_url":"https://github.com/d3x0r.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Join the chat at https://gitter.im/sack-vfs/Lobby](https://badges.gitter.im/sack-vfs/gun-db.svg)](https://gitter.im/sack-vfs/gun-db?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n# gun-db\nODBC/Sqlite native persistence layer for [gun](https://github.com/amark/gun)! GUN is an Open Source Firebase with swappable storage engines (level, SQLite, etc.) that handles data synchronization across machines / devices.\n\n\nGet it by\n\n`npm install gun-db`\n\nUse by\n\n```javascript\nvar Gun = require('gun');\nrequire('gun-db');\n\nvar gun = Gun({\n  file: false // turn off pesky file.js data.json default\n  , db: {\n    file: \"gun.db\"\n    exclusive : false // default\n  }\n});\n```\n\nIf you want to have maximum speed, you can set exclusive, which will gain about 30-40% speed; but you're only allowed one instance of Gun against this database.\nYou can open multiple instances if they don't have the same database name.\n\nCheck the gun docs on how to read/write data, it will then handle sync automatically for you (even to the browser!). Tip: It is a graph database, so you can do key/value, document, relational, or graph based data - here is a [crash course](https://github.com/amark/gun/wiki/graphs) on how to use it.\n\nEnjoy!\n\nOr: Complain about bugs. :)\n\n\n# notes\n   If the filename is '*.db' it defaults to sqlite if it's not it tries it as a DSN (data source name) and then if that doesn't work falls back to use sqlite filename.\n   ODBC can be provided by providing unixodbc on linux, but requires modifying the build to enable; it  is by default only enabled for windows.\n\n   It also ends up writing a sql.config file somewhere ... there's options you can set there to enable sql logging (optionally with data returned) which goes to stderr\n     under windows this goes to (/programdata/freedom collective/node/...) probably.  If your node.exe is not what your running it will be in a folder that is whatever the program name is minus the last (.*)\n     under not windows it probably just goes to ~\n     \n## VFS Usage\n\nThis is an example of how to open the sqlite database in a virtual filesystem storage; the access to the sqlite database \nis then memory mapped.\n\n```\nvar vfs = require( \"sack.vfs\" );\nvar vol = vfs.Volume( \"MountName\", \"vfsFile.dat\" );\n\nvar Gun = require('gun');\nrequire('gun-db');\n\nvar gun = Gun({\n  file: false // turn off pesky file.js data.json default\n  , db: {\n    file: \"$sack@MountName$gun.db\"\n  }\n});\n\n/* ... your appcode ... */\n\n```\n\n\n# Changelog\n- 1.0.571 Fix depending on gun from past 0.9.96 is kinda required (moved symbols)\n- 1.0.570 Fix depending on gun in the future (98 it's only 96)\n- 1.0.569 Update to gun 0.9.98 (internal constant moved)\n- 1.0.568 Fix generating input to wrong object (should be ctx, not gun)\n- 1.0.567 update to gun 0.9.x\n- 1.0.566 for very large nodes, batch results into a single 'in' to gun.\n- 1.0.565 disable exclusive by default; add option to enable it\n- 1.0.564 test sqlite database without exclusive, but with URI filename and nolock option.\n- 1.0.563 remove excess logging\n- 1.0.562 store json string in data  otherwise simple number types come back as numbers and not strings (invalid graph! error)\n- 1.0.561 fix last minute typo\n- 1.0.56 fix writing null value and relation; fixed relation restore; remove unused code; optimize existance check\n- 1.0.55 More cleanup; if database open fails, don't register handlers.\n- 1.0.54 fixed typo\n- 1.0.53 a little cleanup; move varibes to closure (bad debug typo)\n- 1.0.52 remove noisy logging when record already up to date; post reply acking the transation.\n- 1.0.51 Update docs; add gitter badge\n- 1.0.4 fix excessively slow load; misported from sqlite.gun.\n- 1.0.3 fix database performance options.\n- 1.0.2 update to Gun 0.8.3\n- 1.0.1 First usable version\n\n\n\n\n\n### Benchmark Results\n\n```\n(sqlite, native filesystem, windows)\n__ Small Nodes: 10 Properties Each __\nWrite 10000 nodes: : 19841ms; 19.841s; 1.984 ms/node; errors: 0.\nRead 10000 nodes: : 7690ms; 7.69s; 0.769 ms/node; errors: 0.\nUpdate 10000 nodes: : 22273ms; 22.273s; 2.227 ms/node; errors: 0.\nUpdate single field on 10000 nodes: : 3215ms; 3.215s; 0.321 ms/node; errors: 0.\n__ Medium Nodes: 1000 Properties Each __\nWrite 100 nodes: : 18155ms; 18.155s; 179.752 ms/node; errors: 0.\nRead 100 nodes: : 15554ms; 15.554s; 154.000 ms/node; errors: 0.\nUpdate 100 nodes: : 21044ms; 21.044s; 208.356 ms/node; errors: 0.\nUpdate single field on 100 nodes: : 245ms; 0.245s; 2.426 ms/node; errors: 0.\n__ Large Nodes: 10000 Properties Each __\nWrite 10 nodes: : 20773ms; 20.773s; 1888.455 ms/node; errors: 0.\nRead 10 nodes: : 17342ms; 17.342s; 1576.545 ms/node; errors: 0.\nUpdate 10 nodes: : 22796ms; 22.796s; 2072.364 ms/node; errors: 0.\nUpdate single field on 10 nodes: : 1919ms; 1.919s; 174.455 ms/node; errors: 0.\n\n\n(sqlite, vfs)\n__ Small Nodes: 10 Properties Each __\nWrite 10000 nodes: : 11667ms; 11.667s; 1.167 ms/node; errors: 0.\nRead 10000 nodes: : 7086ms; 7.086s; 0.709 ms/node; errors: 0.\nUpdate 10000 nodes: : 13439ms; 13.439s; 1.344 ms/node; errors: 0.\nUpdate single field on 10000 nodes: : 2530ms; 2.53s; 0.253 ms/node; errors: 0.\n__ Medium Nodes: 1000 Properties Each __\nWrite 100 nodes: : 12935ms; 12.935s; 128.069 ms/node; errors: 0.\nRead 100 nodes: : 5792ms; 5.792s; 57.347 ms/node; errors: 0.\nUpdate 100 nodes: : 16061ms; 16.061s; 159.020 ms/node; errors: 0.\nUpdate single field on 100 nodes: : 200ms; 0.2s; 1.980 ms/node; errors: 0.\n__ Large Nodes: 10000 Properties Each __\nWrite 10 nodes: : 16134ms; 16.134s; 1466.727 ms/node; errors: 0.\nRead 10 nodes: : 7653ms; 7.653s; 695.727 ms/node; errors: 0.\nUpdate 10 nodes: : 21076ms; 21.076s; 1916.000 ms/node; errors: 0.\nUpdate single field on 10 nodes: : 1962ms; 1.962s; 178.364 ms/node; errors: 0.\n\n\n(sqlite, vfs, with encryption)\n__ Small Nodes: 10 Properties Each __\nWrite 10000 nodes: : 14899ms; 14.899s; 1.490 ms/node; errors: 0.\nRead 10000 nodes: : 7301ms; 7.301s; 0.730 ms/node; errors: 0.\nUpdate 10000 nodes: : 18248ms; 18.248s; 1.825 ms/node; errors: 0.\nUpdate single field on 10000 nodes: : 3224ms; 3.224s; 0.322 ms/node; errors: 0.\n__ Medium Nodes: 1000 Properties Each __\nWrite 100 nodes: : 20645ms; 20.645s; 204.406 ms/node; errors: 0.\nRead 100 nodes: : 5952ms; 5.952s; 58.931 ms/node; errors: 0.\nUpdate 100 nodes: : 27732ms; 27.732s; 274.574 ms/node; errors: 0.\nUpdate single field on 100 nodes: : 350ms; 0.35s; 3.465 ms/node; errors: 0.\n__ Large Nodes: 10000 Properties Each __\nWrite 10 nodes: : 28288ms; 28.288s; 2571.636 ms/node; errors: 0.\nRead 10 nodes: : 9496ms; 9.496s; 863.273 ms/node; errors: 0.\nUpdate 10 nodes: : 37709ms; 37.709s; 3428.091 ms/node; errors: 0.\nUpdate single field on 10 nodes: : 3587ms; 3.587s; 326.091 ms/node; errors: 0.\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3x0r%2Fgun-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3x0r%2Fgun-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3x0r%2Fgun-db/lists"}