Get the latest tech news

Show HN: NoSQL, but it's SQLite


SQLite-backed key-value store with JS-like object manipulation and automatic JSON serialization. - demo.ts

SQLite-backed key-value store with JS-like object manipulation and automatic JSON serialization. importDatabasefrom'better-sqlite3';import{createDatabaseClient}from'my-partial-db-lib';// 1) Create an in-memory DB and your table(s).constdb=newDatabase(':memory:');db.exec(` CREATE TABLE users ( id TEXT PRIMARY KEY, data JSON );`);// 2) Create the parallel client with separate 'rdr' & 'wtr'.const{ rdr, wtr }=createDatabaseClient(db,{users: {}});// 3) Insert a row in the 'users' table:wtr.users['alice']={name: 'Alice',age: 30};// 4) Check it via the reader:console.log(rdr.users['alice']);// => { name: 'Alice', age: 30 }// 5) Partial update: only set 'nested.foo' -> 42wtr.users['alice'].nested={foo: 42};// 6) Now the row has been updated in the DB:console.log(rdr.users['alice']);/*{ name: 'Alice', age: 30, nested: { foo: 42 }}*/// 7) Check presence:console.log('alice'inrdr.users);// trueconsole.log(rdr.users.has('bob'));// false// 9) Partial delete:deletewtr.users['alice'].nested.foo;// => Removes only nested.foo// 10) Full delete:deletewtr.users['alice'];console.log(rdr.users['alice']);// => undefined */wtr: {[TableNameinkeyofTSchema]: TableWriter<TSchema[TableName]>};}/** Reader interface: bracket-get returns plain objects from memory.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of NoSQL

NoSQL

Related news:

News photo

Tencent builds one NoSQL database to rule all data models

News photo

New Apache Cassandra 5.0 gives open source NoSQL database a scalability and performance boost

News photo

SQL co-creator embraces NoSQL