nekonomi

package module
v0.0.0-...-83a4d3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2023 License: MIT Imports: 7 Imported by: 0

README

NEKONOMI

simple KVS library and command line Tool

CLI

go install github.com/ToshihitoKon/nekonomi/cmd/nekonomi@latest
Usage
% nekonomi
nekonomi is simple KVS command line tool based SQLite3

Usage:
    nekonomi [command]

Available Commands:
    completion  Generate the autocompletion script for the specified shell
    get         Read value
    help        Help about any command
    list        List stored keys
    set         Store new key and value

Flags:
    -h, --help   help for nekonomi

Use "nekonomi [command] --help" for more information about a command.
# set
$ nekonomi set key1 value1

# get
$ nekonomi get key1
value1

# update
$ nekonomi set key1 value1_updated
$ nekonomi get key1
value1_updated

Library

import (
    "github.com/ToshihitoKon/nekonomi"
)

func main() {
    dbid := "db_identifire"
    opts := *nekonomi.Option[]{
        nekonomi.OptionSQLiteFilePath("dbdata/"),
        // nekonomi.OptionSchema("anothe_schema"),
        // nekonomi.OptionReadOnly(),
    }
    nekodb, err := nekonomi.New(dbid, opts)
    _ = err // error handling

    value, err := nekodb.Read("key")
    value, err := nekodb.Write("key", "value")

    value, err := nekodb.Update("key", "value")
    value, err := nekodb.Delete("key")
    // if key is not exist, return nekonomi.ErrKeyNotFound

    schemaList, err := nekodb.SchemaList()
    err := nekodb.SchemaSet("anothe_schema")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound = fmt.Errorf("Error: Key not found")
)

Functions

func OptionReadOnly

func OptionReadOnly() *optReadOnly

func OptionResetDatabase

func OptionResetDatabase() *optResetDatabase

func OptionSchema

func OptionSchema(schema string) *optSchema

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(dbDir, dbId string, opts []Option) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Delete

func (c *Client) Delete(key string) (string, error)

func (*Client) ForceWrite

func (c *Client) ForceWrite(key, value string) (string, error)

func (*Client) ListKeys

func (c *Client) ListKeys() ([]string, error)

func (*Client) Read

func (c *Client) Read(key string) (string, error)

func (*Client) SchemaList

func (c *Client) SchemaList() ([]string, error)

func (*Client) SchemaSet

func (c *Client) SchemaSet(schema string) error

func (*Client) Update

func (c *Client) Update(key, value string) (string, error)

func (*Client) Write

func (c *Client) Write(key, value string) (string, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL