db

package
v0.0.0-...-795d1ad Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	// JSON encoded record or records (can be array or object)
	Record map[string]interface{} `json:"record"`
	// Optional table name. Defaults to 'default'
	Table string `json:"table"`
}

type CreateResponse

type CreateResponse struct {
	// The id of the record (either specified or automatically created)
	Id string `json:"id"`
}

type DbService

type DbService struct {
	// contains filtered or unexported fields
}

func NewDbService

func NewDbService(token string) *DbService

func (*DbService) Create

func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error)

Create a record in the database. Optionally include an "id" field otherwise it's set automatically.

func (*DbService) Delete

func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error)

Delete a record in the database by id.

func (*DbService) Read

func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error)

Read data from a table. Lookup can be by ID or via querying any field in the record.

func (*DbService) Truncate

func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error)

Truncate the records in a table

func (*DbService) Update

func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error)

Update a record in the database. Include an "id" in the record to update.

type DeleteRequest

type DeleteRequest struct {
	// id of the record
	Id string `json:"id"`
	// Optional table name. Defaults to 'default'
	Table string `json:"table"`
}

type DeleteResponse

type DeleteResponse struct {
}

type ReadRequest

type ReadRequest struct {
	// Read by id. Equivalent to 'id == "your-id"'
	Id string `json:"id"`
	// Maximum number of records to return. Default limit is 25.
	// Maximum limit is 1000. Anything higher will return an error.
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
	// 'asc' (default), 'desc'
	Order string `json:"order"`
	// field name to order by
	OrderBy string `json:"orderBy"`
	// Examples: 'age >= 18', 'age >= 18 and verified == true'
	// Comparison operators: '==', '!=', '<', '>', '<=', '>='
	// Logical operator: 'and'
	// Dot access is supported, eg: 'user.age == 11'
	// Accessing list elements is not supported yet.
	Query string `json:"query"`
	// Optional table name. Defaults to 'default'
	Table string `json:"table"`
}

type ReadResponse

type ReadResponse struct {
	// JSON encoded records
	Records []map[string]interface{} `json:"records"`
}

type TruncateRequest

type TruncateRequest struct {
	// Optional table name. Defaults to 'default'
	Table string `json:"table"`
}

type TruncateResponse

type TruncateResponse struct {
	// The table truncated
	Table string `json:"table"`
}

type UpdateRequest

type UpdateRequest struct {
	// The id of the record. If not specified it is inferred from the 'id' field of the record
	Id string `json:"id"`
	// record, JSON object
	Record map[string]interface{} `json:"record"`
	// Optional table name. Defaults to 'default'
	Table string `json:"table"`
}

type UpdateResponse

type UpdateResponse struct {
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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