Categorygithub.com/yusys-cloud/go-jsonstore-rest
modulepackage
2021.1.2+incompatible
Repository: https://github.com/yusys-cloud/go-jsonstore-rest.git
Documentation: pkg.go.dev

# README

Go-Jsonstore-Rest

A quick and easy way to setup a RESTful JSON DATASTORE server for small projects.

Quick Start

Binary Download

https://github.com/yusys-cloud/go-jsonstore-rest/releases

Startup

./go-jsonstore-rest

Replace ./json-db with the path to the drive or directory in which you want to store data.

./go-jsonstore-rest --path=./json-db --port=9999 

RESTful API

通用 JSON 数据操作 API Create

curl localhost:9999/api/kv/meta/node -X POST -d '{"ip": "192.168.49.69","name":"redis-n1","idc":"default","lable":"Redis"}' --header "Content-Type: application/json"

Read

curl localhost:9999/api/kv/meta/node

Update

curl localhost:9999/api/kv/meta/node/node:1429991523109310464 -X PUT -d '{"ip": "192.168.49.69","name":"redis-n2","idc":"default","lable":"Redis"}' --header "Content-Type: application/json"

Delete

curl localhost:9999/api/kv/meta/node/node:1429991523109310464 -X DELETE

Delete All

curl localhost:9999/api/kv/meta/node -X DELETE

Search

curl http://localhost:9999/api/search?b=node&k=node&key=v.name&value=linux&shortBy=weight,desc&offset=10&limit=2

/api/kv/:b/:k

  • 参数 b 为存储的json文件名,类似数据库名称
  • 参数 k 为存储文件中json对象数组名,类似数据库中表名称

/api/search?b=node&k=node&key=v.name&value=linux&shortBy=weight,desc&page=10&limit=2

  • 参数 key 为搜索json对象中字段名称
  • 参数 value 为搜索json对象字段的搜索值
  • page|offset 页码
  • limit|size 每页条数
[GIN-debug] POST   /api/kv/:b/:k             --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).create-fm (3 handlers)
[GIN-debug] GET    /api/kv/:b/:k             --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).readAll-fm (3 handlers)
[GIN-debug] GET    /api/kv/:b/:k/:kid        --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).read-fm (3 handlers)
[GIN-debug] PUT    /api/kv/:b/:k/:kid        --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).update-fm (3 handlers)
[GIN-debug] PUT    /api/kv/:b/:k/:kid/weight --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).updateWeight-fm (3 handlers)
[GIN-debug] DELETE /api/kv/:b/:k/:kid        --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).delete-fm (3 handlers)
[GIN-debug] DELETE /api/kv/:b/:k             --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).deleteAll-fm (3 handlers)
[GIN-debug] GET    /api/search               --> github.com/yusys-cloud/go-jsonstore-rest/rest.(*Storage).search-fm (3 handlers)

Benchmarks

  • BenchmarkQuery100-12 1 2,102,479,566 ns/op
  • BenchmarkCreate100-12 1 1082093859 ns/op

# Packages

Author: [email protected] Date: 2021-03-30 .
Author: [email protected] Date: 2021-09-10 .
Author: [email protected] Date: 2021-03-25 .

# Functions

Needed in order to disable CORS for local development.