jsondb

package module
v0.0.0-...-245a657 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 6 Imported by: 0

README

jsondb

Json file database based on golang

介绍

基于golang的json文件数据库,免安装,直接用

安装

go get github.com/FantasyGao/jsondb

用法

import "github.com/FantasyGao/jsondb"

// 存储的文件位置~/Desktop/db.json
var fileName = "~/Desktop/db.json"

// 创建一个实例
db := jsondb.Create(fileName)

// 写入key为x,值为hello的进缓存内
db.Write("x", "hello")

/**
 * @description 写入key为y,值为world的数据进缓存内
 **/ 
db.Write("y", "world")
  .Write("z", 123456)

/**
 * @description 写入key为m,值为jsondb的,且保存当前的数据进入json文件
 **/ 
db.Write("m", "jsondb").Save()

/**
 * @description 查询key为y的值
 **/ 
val := db.Read("y")

/**
 * @description 查询所有数据,返回为map[string]interface{}类型
 **/ 
all := db.ReadAll()


/**
 * @description 删除key为x的值并且保存进json文件
 **/ 
db.Del("x").Save()

License

This code is distributed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(fileName string) *base

create db install

Types

This section is empty.

Jump to

Keyboard shortcuts

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