Documentation ¶
Overview ¶
Package jsonbox wraps jsonbox API calls.
Create a new Client for use
cl,err := jsonbox.NewClient("https://jsonbox.io/")
Create or add a record
val := []byte(`{"name": "Jon Snow", "age": 25}`) out, err := cl.Create("demobox_6d9e326c183fde7b",val)
Read record(s)
out, err := cl.Read("demobox_6d9e326c183fde7b") fmt.Printf("%s",out)
Query records
out, err := cl.Read("demobox_6d9e326c183fde7b?query_key=name&query_value=arya%20stark") fmt.Printf("%s",out)
Update record
val := []byte(`{"name": "Arya Stark", "age": 18}`) out, err := cl.Update("demobox_6d9e326c183fde7b","5d776b75fd6d3d6cb1d45c53",val) fmt.Printf("%s",out)
Delete record
err := cl.Delete("demobox_6d9e326c183fde7b","5d776b75fd6d3d6cb1d45c53")
Delete All Records
err := cl.Delete(BOX_ID)
List IDs for all records
ids,err := cl.IDs("demobox_6d9e326c183fde7b") fmt.Printf("%s",ids)
Index ¶
- Variables
- func GetRecordID(dat []byte) (string, error)
- type Client
- func (c Client) Create(boxID string, val []byte) ([]byte, error)
- func (c Client) Delete(boxID string, recordID string) error
- func (c Client) DeleteAll(boxID string) error
- func (c Client) IDs(boxID string) ([]string, error)
- func (c Client) Read(boxID string) ([]byte, error)
- func (c Client) Request(method, urlPath string, dat []byte) ([]byte, error)
- func (c Client) Update(boxID string, recordID string, val []byte) ([]byte, error)
- type Meta
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTODO = errors.New("functionality not implemented") ErrName = errors.New("invalid name for either BOX_ID or COLLECTION") )
Errors returned when working with jsonbox package
View Source
var NameRegExp = regexp.MustCompile("^[a-zA-Z0-9_]*$")
NameRegExp defines valid BOX_ID or COLLECTION names reges
Functions ¶
func GetRecordID ¶
GetRecordID returns the id of a record, or the first ID if multiple records
Types ¶
type Client ¶
Client defines the structure of a jsonbox client
Click to show internal directories.
Click to hide internal directories.