bun-sqlite-key-value
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -9,5 +9,6 @@ import { BunSqliteKeyValue } from "../src" | ||
store.set("language:it", "Italian") | ||
store.set("my-null-value", null) | ||
const items = store.getItemsObject("language:") | ||
console.log(items) | ||
const items1 = store.getItemsObject("language:") | ||
console.log(items1) | ||
// -> { | ||
@@ -18,1 +19,13 @@ // "language:de": "German", | ||
// } | ||
const items2 = store.getItemsObject([ | ||
"language:de", | ||
"my-null-value", | ||
"my-unknown-key" | ||
]) | ||
console.log(items2) | ||
// -> { | ||
// "language:de": "German", | ||
// "my-null-value": null, | ||
// "unknown-key": undefined, | ||
// } |
{ | ||
"name": "bun-sqlite-key-value", | ||
"description": "A super fast key-value store with SQLite that uses bun:sqlite and v8 as faster JSON replacement.", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"author": "Gerold Penz<gerold@gp-softwaretechnik.at>", | ||
@@ -6,0 +6,0 @@ "module": "src/index.ts", |
@@ -298,1 +298,27 @@ # Bun SQLite Key Value | ||
``` | ||
### Read and write binary files | ||
SQLite has no problem with large images/binaries. | ||
#### Example | ||
```typescript | ||
import { BunSqliteKeyValue } from "bun-sqlite-key-value" | ||
const store = new BunSqliteKeyValue() | ||
// Read file from filesystem | ||
const sourceFile = Bun.file("<Source File Path>") | ||
// Write ArrayBuffer into database (async !!!) | ||
store.set("my-image", await sourceFile.arrayBuffer()) | ||
// Read ArrayBuffer from database | ||
const targetArrayBuffer = store.get("my-image") | ||
// Write target file to filesystem (async !!!) | ||
await Bun.write(Bun.file("<Target File Path>"), targetArrayBuffer) | ||
``` |
@@ -7,2 +7,3 @@ import { expect, test } from "bun:test" | ||
const KEY_2: string = "test-key-2" | ||
const KEY_3: string = "test-key-3" | ||
const STRING_VALUE_1: string = "Hello world!" | ||
@@ -242,1 +243,22 @@ const STRING_VALUE_2: string = "Hello moon!" | ||
}) | ||
test("Get items as Object", () => { | ||
const store: BunSqliteKeyValue = new BunSqliteKeyValue() | ||
store.set<string>(KEY_1, STRING_VALUE_1) | ||
store.set<string>(KEY_2, STRING_VALUE_2) | ||
store.set(KEY_3, null) | ||
expect(store.getItemsObject([ | ||
KEY_1, | ||
KEY_2, | ||
KEY_3, | ||
"unknown-key" | ||
])).toEqual({ | ||
[KEY_1]: STRING_VALUE_1, | ||
[KEY_2]: STRING_VALUE_2, | ||
[KEY_3]: null, | ||
"unknown-key": undefined | ||
}) | ||
}) |
40528
22
625
324