Documentation
¶
Index ¶
- Constants
- Variables
- func FormatDateLocal(utcStr string) string
- func LqdTasksSchema() map[string]any
- func StartPocketBase(workDir string) (*exec.Cmd, error)
- func WaitForReady(healthURL string, timeout time.Duration) error
- type Client
- func (c *Client) CollectionExists(name string) (bool, error)
- func (c *Client) CreateCollection(schema map[string]any) error
- func (c *Client) CreateRecord(collection string, data map[string]any) error
- func (c *Client) DeleteCollection(name string) error
- func (c *Client) DeleteRecord(collection, recordID string) error
- func (c *Client) FetchRecords(collection, filter, sort string, limit ...int) ([]map[string]any, error)
- func (c *Client) Token() string
- func (c *Client) UpdateRecord(collection, recordID string, data map[string]any) error
Constants ¶
const DateFormat = "2006-01-02 15:04:05.000Z"
DateFormat is the ISO date format used for PocketBase date/datetime record fields.
Variables ¶
var ( ErrCannotConnect = errors.New("cannot connect to PocketBase") ErrAuthFailed = errors.New("PocketBase authentication failed") ErrUnexpectedStatus = errors.New("unexpected status from PocketBase") )
Sentinel errors for PocketBase client operations.
var ErrPocketBaseNotFound = errors.New("pocketbase executable not found in $PATH or ~/.local/bin")
ErrPocketBaseNotFound is returned when the pocketbase binary cannot be located.
var ErrWaitTimeout = errors.New("timed out waiting for service to be ready")
ErrWaitTimeout is returned when WaitForReady times out.
Functions ¶
func FormatDateLocal ¶
FormatDateLocal parses a PocketBase UTC datetime string and returns it in local time as "YYYY-MM-DD HH:MM". Returns the raw string if parsing fails.
func LqdTasksSchema ¶
LqdTasksSchema returns the PocketBase collection schema for lqd_tasks. Go code is the source of truth — not PB migrations.
func StartPocketBase ¶
StartPocketBase starts pocketbase serve as a managed subprocess from workDir. Stdout and stderr are inherited so PocketBase logs appear in the same terminal. The caller is responsible for calling cmd.Process.Kill() on shutdown.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal PocketBase HTTP client.
func NewClientWithToken ¶
NewClientWithToken returns a client pre-loaded with an existing auth token. Use when a token has already been obtained (e.g. at dashboard startup) to avoid a redundant authentication round-trip.
func (*Client) CollectionExists ¶
CollectionExists checks if a collection exists in PocketBase.
func (*Client) CreateCollection ¶
CreateCollection creates a new collection with the given schema.
func (*Client) CreateRecord ¶
CreateRecord creates a record in the given collection.
func (*Client) DeleteCollection ¶
DeleteCollection deletes a collection by name. It first fetches the collection to get its ID.
func (*Client) DeleteRecord ¶
DeleteRecord deletes a record by ID from the given collection.
func (*Client) FetchRecords ¶
func (c *Client) FetchRecords(collection, filter, sort string, limit ...int) ([]map[string]any, error)
FetchRecords fetches all records from a collection, handling pagination. Optional filter and sort parameters are passed as PB query params. If limit > 0, fetches at most that many records (single page).