easyboltdb

package module
v0.0.0-...-9a8f8c3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

README

easyboltdb

easy to use boltDB

package main

import (
	"log"

	"github.com/fy138/easyboltdb"
)

func main() {
	//create a db and a table
        // db  file name and  bucket name
	sdb, err := easyboltdb.NewEasyBolt("name.db", "user")
	if err != nil {
		log.Fatal(err)
	}
	//save 
	sdb.Update("author", "fy138")
	sdb.Update("today", "2022-01-27")
	//get 
	n, err := sdb.View("author")
	if err != nil {
		log.Fatal(err)
	}
	log.Println("author:", n)

	c, err := sdb.View("today")
	if err != nil {
		log.Fatal(err)
	}
	log.Println("today:", c)

	sdb.Close()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EasyBolt

type EasyBolt struct {
	DB     *bolt.DB
	Bucket string
}

func NewEasyBolt

func NewEasyBolt(dbname, bucket string) (*EasyBolt, error)

func (*EasyBolt) Close

func (s *EasyBolt) Close()

func (*EasyBolt) Update

func (s *EasyBolt) Update(key, value string) error

func (*EasyBolt) View

func (s *EasyBolt) View(key string) (str string, err error)

Jump to

Keyboard shortcuts

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