Skip to content

FantasyGao/jsondb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Json file database based on golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages