KVBase is a lightweight key-value store for Bun. It internally uses bun:sqlite for the storage.
Lilo is a quick Minecraft server lookup and statistics provider and as such a service relies on performance and stability, we've decided to switch over to bun and use this modified kvb fork as a easy to use and maintain database.
But what does this fork modify?
Well, it mainly modifies the syntax in order to keep it very similar
to node-redis & to expand kvb's capabilities.
Thank you gaurishhs for providing the base of kvb ❤️
git submodule add https://github.com/LiloLookup/kvbWarning: Usage might modify over the next time without a proper documentation. We will promise to update the documentation once we're comfortable about the end-result.
import {KVBase} from 'kvb';
const db = new KVBase();
await db.set('foo', 'bar');
await db.get('foo'); // bar
await db.delete('foo');
await db.update('foo', 'bar');Note: If no
options.bunOptions.filenameis given, Memory Storage will be used.
KVBase is written in Typescript and has full types support.
Use Typescript Generics while creating a new instance of KVBase to get the correct types.
import {KVBase} from 'kvb';
const db = new KVBase<string>();
await db.set('foo', 'bar');
await db.get('foo'); // barCreates a new instance of KVBase.
Type: KVBaseOptions
Source: src/index.ts
interface KVBaseOptions {
/**
* Bun options given to the bun:sqlite instance.
*/
bunOptions?: {
filename?: string;
options?: number | { readonly?: boolean; create?: boolean; readwrite?: boolean; }
};
/**
* The name of the table to use.
* @Default 'kvbase'
*/
tableName?: string;
}Sets a key-value pair in the database.
Gets a value from the database.
Deletes a key-value pair from the database.
Updates a key-value pair in the database.
Close the database connection.
MIT © Gaurish Sethia. See LICENSE for more details.