serviceapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
}

Client is a stub.

func NewClient

func NewClient(caller any) Client

func (Client) BulkCreate

func (_c Client) BulkCreate(ctx context.Context, objs []*Obj) (objKeys []ObjKey, err error)

func (Client) BulkDelete

func (_c Client) BulkDelete(ctx context.Context, objKeys []ObjKey) (deletedKeys []*ObjKey, err error)

func (Client) BulkLoad

func (_c Client) BulkLoad(ctx context.Context, objKeys []ObjKey) (books []*Obj, err error)

func (Client) BulkRevise

func (_c Client) BulkRevise(ctx context.Context, objs []*Obj) (revisedKeys []ObjKey, err error)

func (Client) BulkStore

func (_c Client) BulkStore(ctx context.Context, objs []*Obj) (storedKeys []ObjKey, err error)

func (Client) Count

func (_c Client) Count(ctx context.Context, query Query) (count int, err error)

func (Client) Create

func (_c Client) Create(ctx context.Context, obj *Obj) (objKey ObjKey, err error)

func (Client) Delete

func (_c Client) Delete(ctx context.Context, objKey ObjKey) (deleted bool, err error)

func (Client) List

func (_c Client) List(ctx context.Context, query Query) (objs []*Obj, totalCount int, err error)

func (Client) Load

func (_c Client) Load(ctx context.Context, objKey ObjKey) (obj *Obj, found bool, err error)

func (Client) Lookup

func (_c Client) Lookup(ctx context.Context, query Query) (obj *Obj, found bool, err error)

func (Client) MustDelete

func (_c Client) MustDelete(ctx context.Context, objKey ObjKey) (err error)

func (Client) MustLoad

func (_c Client) MustLoad(ctx context.Context, objKey ObjKey) (obj *Obj, err error)

func (Client) MustLookup

func (_c Client) MustLookup(ctx context.Context, query Query) (obj *Obj, err error)

func (Client) MustRevise

func (_c Client) MustRevise(ctx context.Context, obj *Obj) (err error)

func (Client) MustStore

func (_c Client) MustStore(ctx context.Context, obj *Obj) (err error)

func (Client) Purge

func (_c Client) Purge(ctx context.Context, query Query) (deletedKeys []*ObjKey, err error)

func (Client) Revise

func (_c Client) Revise(ctx context.Context, obj *Obj) (revised bool, err error)

func (Client) Store

func (_c Client) Store(ctx context.Context, obj *Obj) (stored bool, err error)

type Obj

type Obj struct {
	Key       ObjKey    `json:"key,omitzero"`
	Revision  int       `json:"revision,omitzero"`
	CreatedAt time.Time `json:"createdAt,omitzero"`
	UpdatedAt time.Time `json:"updatedAt,omitzero"`

	// HINT: Define the fields of the object here
	Example string `json:"example,omitzero" jsonschema:"-"` // Do not remove the example
}

Obj

func (*Obj) Validate

func (obj *Obj) Validate(ctx context.Context) error

Validate validates the object before storing it.

type ObjKey

type ObjKey struct {
	ID int `json:"id,omitempty"`
}

ObjKey is the ID of the object.

func ParseKey

func ParseKey(id any) ObjKey

ParseKey returns a key from its scrambled (string) or unscrambled (int) ID. A zero key is returned if the ID can't be parsed.

func (ObjKey) Equal

func (k ObjKey) Equal(other ObjKey) bool

Equal checks two keys for equality.

func (ObjKey) IsZero

func (k ObjKey) IsZero() bool

IsZero tests if the ID is zero. Valid IDs starts from 1.

func (ObjKey) MarshalJSON

func (k ObjKey) MarshalJSON() (b []byte, err error)

MarshalJSON overrides JSON serialization to encrypt the ID.

func (*ObjKey) Scan

func (k *ObjKey) Scan(value interface{}) error

Scan implements the Scanner interface.

func (ObjKey) String

func (k ObjKey) String() string

String returns the ID of the key scrambled.

func (*ObjKey) UnmarshalJSON

func (k *ObjKey) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides JSON deserialization to decrypt the ID.

func (ObjKey) Value

func (k ObjKey) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Query

type Query struct {
	Key  ObjKey   `json:"key,omitzero"`
	Keys []ObjKey `json:"keys,omitzero"`
	Q    string   `json:"q,omitzero"`

	Select  string `json:"select,omitzero"`
	OrderBy string `json:"orderBy,omitzero"`
	Limit   int    `json:"limit,omitzero"`
	Offset  int    `json:"offset,omitzero"`

	// HINT: Add additional filtering options here
	Example string `json:"example,omitzero"` // Do not remove the example
}

Query is used to select a subset of records using filtering options.

Select is an optional comma-separated subset of fields to include in the result. For example, "column_one,column_two". If not specified, all fields are included by default.

OrderBy is a comma-separated subset of fields to order the results by. A hyphen before the field name denotes a descending order. For example, "-column_one,column_two". If not specified, the default sort order is by "id".

func (*Query) Validate

func (q *Query) Validate(ctx context.Context) error

Validate validates the filtering options of the query.

Jump to

Keyboard shortcuts

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