Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 618 Bytes

README.md

File metadata and controls

41 lines (30 loc) · 618 Bytes

jdb

Compressed json flatfile "database" (it's golang map datatype actualy) with simple key/value api

Example how to open (one time file read), read from db and save it to file

package main

import (
	"github.com/puresoul/jdb"
	"fmt"
)

func main() {
	// Create database file
	d := jdb.Open("test.db")

	// Insert string
	d.Map["test"] = "test"
	fmt.Println(d.Map)

	// Save
	_ = d.Close()

	d = jdb.Open("test.db")

	// Read String
	t := d.ReadStr("test")
	fmt.Println(t)

	// Write Int
	d.Map["tst"] = 123
	_ = d.Close()

	d = jdb.Open("test.db")

	// Read Int
	i := d.ReadInt("tst")
	fmt.Println(i+i)
}
``