osqlite
v1.1.2
Published
[osqlite](https://github.com/131/osqlite) gives you an [sqlite3](https://github.com/mapbox/node-sqlite3) database on an object storage backed (like [openstack swift](https://github.com/131/swift))
Downloads
4
Readme
osqlite gives you an sqlite3 database on an object storage backed (like openstack swift).
Motivation
Object storage is, by far, the cheapest cloud storage solution. If i want to store TB of contents, a CAS designed container is an excellent choice. But CAS relies on external database to handle file properties (name, directories & properties). osqlite allows you to store your database in the very same object storage container your CAS relies on.
osqlite uses the SQLite3 "hot" backup/replication API to publish current database and register triggers on the SQLite3 update hook API to know "when" to sync.
Usage example
const OSQLite = require('osqlite');
const creds = require('./credentials');
const Context = require('swift/context');
var ctx = await Context.build(creds);
var lnk = OSQLite.build({
backend : {type : 'swift', ctx},
container : 'container',
filename : 'index.sqlite',
});
await lnk.query("CREATE TABLE IF NOT EXISTS lorem (info TEXT)");
console.log("Database contains %d entries", await lnk.value("SELECT COUNT(*) FROM lorem"));
for(let var i=0;i<10;i++) {
let message = "foobar" + Date.now();
console.log("Updating sqlite database");
await lnk.insert("lorem", {"info": message});
await sleep(200);
}
await lnk.close();//flush all to remote endpoint
Efficiency, triggers & throttle
osqlite will trigger synchronisation (object storage write) after each update/delete/insert following a cargo pattern.