JSON version of Enmap, because why not...
npm install ghomap@latest
import Ghomap from "ghomap"
const db = new Ghomap()
const Ghomap = require("ghomap")
const db = new Ghomap()
Ghomap includes type definitions.
import Ghomap from "ghomap"
const db = new Ghomap<any>()
import Ghomap from "ghomap"
const db = new Ghomap<number>()
db.open().then(async () => {
// set value
await db.set("key", 42)
// get value
const value = await db.get("key")
console.log(value)
// output => 42
})
import Ghomap from "ghomap"
const users = new Ghomap<User>("users")
const numbers = new Ghomap<number[]>("numbers")
const descriptions = new Ghomap<string>("descriptions")
Ghomap.openAll().then(async () => {
// set value
await users.set(userId, {
name: "bob",
age: 42,
})
// ensure array value
let list = await numbers.ensure("list", [42])
console.log(list)
// output => [42]
// push in arrray value
await numbers.push("list", 66, 33)
console.log(await numbers.get("list"))
// output => [42, 66, 33]
})