pocketbase

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 19 Imported by: 0

README

PocketBase

Project

I forked this to run some of my personal projects. I'm open for any contribution.

Roadmap

Note This will be updated as we go.****

  • [] Add observability support.
  • [] Improve pocketbase version compatibility

Compatibility

  • v0.22.0 version of SDK is compatible with Pocketbase v0.22.x
  • v0.21.0 version of SDK is compatible with Pocketbase v0.21.x
  • v0.20.0 version of SDK is compatible with Pocketbase v0.20.x
  • v0.19.0 version of SDK is compatible with Pocketbase v0.19.x
  • v0.13.0 version of SDK is compatible with Pocketbase v0.13.x and higher
  • v0.12.0 version of SDK is compatible with Pocketbase v0.12.x
  • v0.11.0 version of SDK is compatible with Pocketbase v0.11.x
  • v0.10.1 version of SDK is compatible with Pocketbase v0.10.x
  • v0.9.2 version of SDK is compatible with Pocketbase v0.9.x (SSE & generics support introduced)
  • v0.8.0 version of SDK is compatible with Pocketbase v0.8.x

PocketBase

Pocketbase is a simple, self-hosted, open-source, no-code, database for your personal data. It's a great alternative to Airtable, Notion, and Google Sheets. Source code is available on GitHub

Currently supported operations

This SDK doesn't have feature parity with official SDKs and supports the following operations:

  • Authentication - anonymous, admin and user via email/password
  • Create
  • Update
  • Delete
  • List - with pagination, filtering, sorting
  • Backups - with create, restore, delete, upload, download and list all available downloads
  • Other - feel free to create an issue or contribute

Usage & examples

Simple list example without authentication (assuming your collections are public):

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

func main() {
 client := pocketbase.NewClient("http://localhost:8090")

 // You can list with pagination:
 response, err := client.List("posts_public", pocketbase.ParamsList{
  Page: 1, Size: 10, Sort: "-created", Filters: "field~'test'",
 })
 if err != nil {
  log.Fatal(err)
 }
 log.Print(response.TotalItems)

 // Or you can use the FullList method (v0.0.7)
 response, err := client.FullList("posts_public", pocketbase.ParamsList{
  Sort: "-created", Filters: "field~'test'",
 })
 if err != nil {
  log.Fatal(err)
 }

 log.Print(response.TotalItems)
}

Creating an item with admin user (auth via email/pass). Please note that you can pass map[string]any or struct with JSON tags as a payload:

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

func main() {
 client := pocketbase.NewClient("http://localhost:8090", 
  pocketbase.WithAdminEmailPassword("admin@admin.com", "admin@admin.com"))
 response, err := client.Create("posts_admin", map[string]any{
  "field": "test",
 })
 if err != nil {
  log.Fatal(err)
 }
 log.Print(response.ID)
}

For even easier interaction with collection results as user-defined types, you can go with CollectionSet:

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

type post struct {
 ID      string
 Field   string
 Created string
}

func main() {
 client := pocketbase.NewClient("http://localhost:8090")
 collection := pocketbase.CollectionSet[post](client, "posts_public")

 // List with pagination
 response, err := collection.List(pocketbase.ParamsList{
  Page: 1, Size: 10, Sort: "-created", Filters: "field~'test'",
 })
 if err != nil {
  log.Fatal(err)
 }

 // FullList also available for collections:
 response, err := collection.FullList(pocketbase.ParamsList{
  Sort: "-created", Filters: "field~'test'",
 })
 if err != nil {
  log.Fatal(err)
 }
 
    log.Printf("%+v", response.Items)
}

Realtime API via Server-Sent Events (SSE) is also supported:

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

type post struct {
 ID      string
 Field   string
 Created string
}

func main() {
 client := pocketbase.NewClient("http://localhost:8090")
 collection := pocketbase.CollectionSet[post](client, "posts_public")
 response, err := collection.List(pocketbase.ParamsList{
  Page: 1, Size: 10, Sort: "-created", Filters: "field~'test'",
 })
 if err != nil {
  log.Fatal(err)
 }
 
 stream, err := collection.Subscribe()
 if err != nil {
  log.Fatal(err)
 }
 defer stream.Unsubscribe()
 <-stream.Ready()
 for ev := range stream.Events() {
  log.Print(ev.Action, ev.Record)
 }
}

You can fetch a single record by its ID using the One method to get the raw map, or the OneTo method to unmarshal directly into a custom struct.

Here's an example of fetching a single record as a map:

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

func main() {
 client := pocketbase.NewClient("http://localhost:8090")

 // Fetch a single record by ID
 record, err := client.One("posts_public", "record_id")
 if err != nil {
  log.Fatal(err)
 }

 // Access the record fields
 log.Print(record["field"])
}

You can fetch and unmarshal a single record directly into your custom struct using OneTo:

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

type Post struct {
 ID    string `json:"id"`
 Field string `json:"field"`
}

func main() {
 client := pocketbase.NewClient("http://localhost:8090")

 // Fetch a single record by ID and unmarshal into struct
 var post Post
 err := client.OneTo("posts", "post_id", &post)
 if err != nil {
  log.Fatal(err)
 }

 // Access the struct fields
 log.Printf("Fetched Post: %+v\n", post)
}

Trigger to create a new backup.

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

func main() {
 client := pocketbase.NewClient("http://localhost:8090", 
  pocketbase.WithAdminEmailPassword("admin@admin.com", "admin@admin.com"))
 err := client.Backup().Create("foobar.zip")
 if err != nil {
     log.Println("create new backup failed")
  log.Fatal(err)
 }
}

Authenticate user from collection

package main

import (
 "log"

 "github.com/Forty2Co/pocketbase"
)

type User struct {
 AuthProviders    []interface{} `json:"authProviders"`
 UsernamePassword bool          `json:"usernamePassword"`
 EmailPassword    bool          `json:"emailPassword"`
 OnlyVerified     bool          `json:"onlyVerified"`
}

func main() {
 client := pocketbase.NewClient("http://localhost:8090")
 response, err := pocketbase.CollectionSet[User](client, "users").AuthWithPassword("user", "user@user.com")
 if err != nil {
  log.Println("user-authentication failed")
  log.Fatal(err)
  return
 }
 log.Println("authentication successful")
 log.Printf("JWT-token: %s\n", response.Token)
}

More examples can be found in:

Development

Makefile targets

Server Management:

  • make serve - builds all binaries and runs local PocketBase server in foreground
  • make serve-bg - starts PocketBase server in background (saves PID for management)
  • make serve-stop - stops the background PocketBase server
  • make serve-status - checks if the server is running
  • make serve-restart - restarts the background server

Testing:

  • make test-integration - runs all tests with automatic server management (recommended)
  • make test-unit - runs only unit tests (fast, no server required)
  • make test - runs tests (requires PocketBase server running manually)

Development:

  • make build - builds all binaries (examples and PocketBase server)
  • make check - runs linters and security checks (run this before commit)
  • make clean - removes build artifacts and stops any running servers
  • make help - shows help and other targets

Contributing

⚠️ IMPORTANT: VERSION File Requirement

All pull requests MUST update the VERSION file or they will be automatically rejected.

This project enforces semantic versioning - every change must be properly versioned:

  • Bug fixes: Increment patch version (0.2.10.2.2)
  • New features: Increment minor version (0.2.10.3.0)
  • Breaking changes: Increment major version (0.2.11.0.0)

PRs without VERSION updates will fail CI checks and cannot be merged.

Development Requirements

  • Go 1.24+ (for making changes in the Go code)
  • While developing use WithDebug() client option to see HTTP requests and responses
  • Update VERSION file in every PR (see warning above)
  • Make sure that all checks are green (run make check before commit)
  • Make sure that all tests pass (run make test-integration before commit)
  • Create a PR with your changes and wait for review

Running Tests

Recommended approach:

make test-integration  # Automatically starts server, runs tests, stops server

Manual approach:

# Terminal 1: Start server
make serve

# Terminal 2: Run tests
make test

# Terminal 1: Stop server (Ctrl+C)

Unit tests only:

make test-unit  # Fast tests that don't require a server

Release Process

This project uses semantic versioning and automated releases via GitHub Actions.

Automated Release Workflow

Releases are automatically triggered when pull requests are merged to the main branch with VERSION file changes:

  1. Update VERSION file in your pull request (e.g., 0.2.1)
  2. Merge PR to main - This automatically:
    • Detects VERSION file changes
    • Creates git tag (e.g., v0.2.1)
    • Triggers release build workflow
    • Creates GitHub release with auto-generated notes
    • Builds and uploads release artifacts

Version Management

  • VERSION file - Contains the current version (e.g., 0.2.0)
  • Git tags - Automatically created (e.g., v0.2.0)
  • Release notes - Auto-generated from PR titles and commit messages
  • Automatic builds - Version info is injected into binaries

Creating a Release

📋 Note: VERSION file updates are mandatory for all PRs. The CI system will automatically reject any pull request that doesn't include a VERSION change.

  1. Update VERSION file in a pull request:

    # Create feature branch
    git checkout -b release/0.2.1
    
    # Update VERSION file
    echo "0.2.1" > VERSION
    
    # Commit and push
    git add VERSION
    git commit -m "chore: bump version to 0.2.1"
    git push origin release/0.2.1
    
  2. Create and merge pull request:

    • Create PR from your branch to main
    • Include release notes in PR description
    • Merge PR to main
  3. Automatic release process:

    • GitHub Actions detects VERSION file change
    • Creates git tag v0.2.1
    • Builds binaries and creates GitHub release
    • Release notes are auto-generated from PR and commit history

Version Strategy

  • Patch (0.2.1) - Bug fixes, documentation updates
  • Minor (0.3.0) - New features, API additions
  • Major (1.0.0) - Breaking changes

Manual Release (if needed)

For manual releases, you can still use the traditional approach:

# Update VERSION file
echo "0.2.1" > VERSION

# Commit changes
git add VERSION
git commit -m "chore: bump version to 0.2.1"
git push origin main

# The automated workflow will handle the rest

Checking Version

make version  # Shows current version, commit, build time

Documentation

Overview

Package pocketbase provides a Go SDK for interacting with PocketBase APIs.

This package offers type-safe, idiomatic Go interfaces for PocketBase operations including authentication, CRUD operations, real-time subscriptions, and backup management.

Example usage:

client := pocketbase.NewClient("http://localhost:8090")
records, err := client.List("posts", pocketbase.ParamsList{})

For type-safe operations, use CollectionSet:

collection := pocketbase.CollectionSet[MyStruct](client, "posts")
records, err := collection.List(pocketbase.ParamsList{})

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidResponse = errors.New("invalid response")

ErrInvalidResponse is returned when PocketBase returns an invalid response.

Functions

func EnvIsTruthy

func EnvIsTruthy(key string) bool

EnvIsTruthy checks if an environment variable is set to a truthy value (1, true, yes).

Types

type AuthMethod

type AuthMethod struct {
	AuthProviders    []AuthProvider `json:"authProviders"`
	UsernamePassword bool           `json:"usernamePassword"`
	EmailPassword    bool           `json:"emailPassword"`
	OnlyVerified     bool           `json:"onlyVerified"`
}

AuthMethod represents the available authentication methods for a collection.

type AuthMethodsResponse

type AuthMethodsResponse struct {
	Password passwordResponse `json:"password"`
	OAuth2   oauth2Response   `json:"oauth2"`
	MFA      mfaResponse      `json:"mfa"`
	OTP      otpResponse      `json:"otp"`

	// legacy fields
	// @todo remove after dropping v0.22 support
	AuthProviders    []providerInfo `json:"authProviders"`
	UsernamePassword bool           `json:"usernamePassword"`
	EmailPassword    bool           `json:"emailPassword"`
}

AuthMethodsResponse represents the response structure for authentication methods. Borrowed from https://github.com/pocketbase/pocketbase/blob/844f18cac379fc749493dc4dd73638caa89167a1/apis/record_auth_methods.go#L52

type AuthProvider

type AuthProvider struct {
	Name                string `json:"name"`
	DisplayName         string `json:"displayName"`
	State               string `json:"state"`
	AuthURL             string `json:"authUrl"`
	CodeVerifier        string `json:"codeVerifier"`
	CodeChallenge       string `json:"codeChallenge"`
	CodeChallengeMethod string `json:"codeChallengeMethod"`
}

AuthProvider represents an OAuth2 authentication provider configuration.

type AuthRefreshResponse

type AuthRefreshResponse struct {
	Record struct {
		Avatar          string `json:"avatar"`
		CollectionID    string `json:"collectionId"`
		CollectionName  string `json:"collectionName"`
		Created         string `json:"created"`
		Email           string `json:"email"`
		EmailVisibility bool   `json:"emailVisibility"`
		ID              string `json:"id"`
		Name            string `json:"name"`
		Updated         string `json:"updated"`
		Username        string `json:"username"`
		Verified        bool   `json:"verified"`
	} `json:"record"`
	Token string `json:"token"`
}

AuthRefreshResponse represents the response from authentication token refresh.

type AuthWithOauth2Response

type AuthWithOauth2Response struct {
	Token string `json:"token"`
}

AuthWithOauth2Response represents the response from OAuth2 authentication.

type AuthWithPasswordResponse

type AuthWithPasswordResponse struct {
	Record Record `json:"record"`
	Token  string `json:"token"`
}

AuthWithPasswordResponse represents the response from password authentication.

type Backup

type Backup struct {
	*Client
}

Backup provides methods for managing PocketBase backup operations.

func (Backup) Create

func (b Backup) Create(key ...string) error

Create initializes a new backup.

func (Backup) Delete

func (b Backup) Delete(key string) error

Delete deletes a single backup file.

Example:

file, _ := os.Open("./backups/pb_backup.zip")
defer file.Close()
_ = defaultClient.Backup().Upload("mybackup.zip", file)

func (Backup) FullList

func (b Backup) FullList() ([]ResponseBackupFullList, error)

FullList returns list with all available backup files.

func (Backup) GetDownloadURL

func (b Backup) GetDownloadURL(token string, key string) (string, error)

GetDownloadURL builds a download url for a single existing backup using an admin file token and the backup file key.

The file token can be generated via `client.Files().GetToken()`.

func (Backup) Restore

func (b Backup) Restore(key string) error

Restore initializes an app data restore from an existing backup.

func (Backup) Upload

func (b Backup) Upload(key string, reader io.Reader) error

Upload uploads an existing backup file.

type Client

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

Client represents a PocketBase API client with authentication and HTTP capabilities.

func NewClient

func NewClient(url string, opts ...ClientOption) *Client

NewClient creates a new PocketBase API client with the specified URL and options.

func (*Client) AuthStore

func (c *Client) AuthStore() authStore

AuthStore returns the client's authentication store.

func (*Client) Authorize

func (c *Client) Authorize() error

Authorize performs authentication using the configured authorization method.

func (*Client) Backup

func (c *Client) Backup() Backup

Backup returns a Backup instance for managing backup operations.

func (*Client) Create

func (c *Client) Create(collection string, body any) (ResponseCreate, error)

Create creates a new record in the specified collection.

func (*Client) Delete

func (c *Client) Delete(collection string, id string) error

Delete removes a record from the specified collection.

func (*Client) Files

func (c *Client) Files() Files

Files returns a Files instance for managing file operations.

func (*Client) FullList

func (c *Client) FullList(collection string, params ParamsList) (ResponseList[map[string]any], error)

FullList retrieves all records from the specified collection without pagination.

func (*Client) Get

func (c *Client) Get(path string, result any, onRequest func(*resty.Request), onResponse func(*resty.Response)) error

Get performs a GET request to the specified path with optional request/response hooks.

func (*Client) List

func (c *Client) List(collection string, params ParamsList) (ResponseList[map[string]any], error)

List retrieves a paginated list of records from the specified collection.

func (*Client) One

func (c *Client) One(collection string, id string) (map[string]any, error)

One retrieves a single record from the specified collection.

func (*Client) OneTo

func (c *Client) OneTo(collection string, id string, result any) error

OneTo retrieves a single record and unmarshals it into the provided result.

func (*Client) Update

func (c *Client) Update(collection string, id string, body any) error

Update updates a record in the specified collection.

type ClientOption

type ClientOption func(*Client)

ClientOption is a function type for configuring Client instances.

func WithAdminEmailPassword

func WithAdminEmailPassword(email, password string) ClientOption

WithAdminEmailPassword configures admin authentication using email and password.

func WithAdminEmailPassword22

func WithAdminEmailPassword22(email, password string) ClientOption

WithAdminEmailPassword22 configures admin authentication using email and password (legacy version).

func WithAdminToken

func WithAdminToken(token string) ClientOption

WithAdminToken configures admin authentication using a token.

func WithAdminToken22

func WithAdminToken22(token string) ClientOption

WithAdminToken22 configures admin authentication using a token (legacy version).

func WithRestDebug

func WithRestDebug() ClientOption

WithRestDebug enables REST API debug logging for the client.

func WithRetry

func WithRetry(count int, waitTime, maxWaitTime time.Duration) ClientOption

WithRetry set the retry settings for requests (defaults: count=3, waitTime=3s, maxWaitTime=10s)

func WithSseDebug

func WithSseDebug() ClientOption

WithSseDebug enables Server-Sent Events debug logging for the client.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout set the timeout for requests

func WithUserEmailPassword

func WithUserEmailPassword(email, password string) ClientOption

WithUserEmailPassword configures user authentication using email and password.

func WithUserEmailPasswordAndCollection

func WithUserEmailPasswordAndCollection(email, password, collection string) ClientOption

WithUserEmailPasswordAndCollection configures user authentication for a specific collection.

func WithUserToken

func WithUserToken(token string) ClientOption

WithUserToken configures user authentication using a token.

type Collection

type Collection[T any] struct {
	*Client
	Name               string
	BaseCollectionPath string
}

Collection represents a type-safe wrapper around a PocketBase collection.

func CollectionSet

func CollectionSet[T any](client *Client, collection string) *Collection[T]

CollectionSet creates a new type-safe collection wrapper for the specified collection.

func (*Collection[T]) AuthRefresh

func (c *Collection[T]) AuthRefresh() (AuthRefreshResponse, error)

AuthRefresh refreshes the current authenticated record instance and * returns a new token and record data.

func (*Collection[T]) AuthWithOAuth2Code

func (c *Collection[T]) AuthWithOAuth2Code(provider string, code string, codeVerifier string, redirectURL string) (AuthWithOauth2Response, error)

AuthWithOAuth2Code authenticate a single auth collection record with OAuth2 code.

If you don't have an OAuth2 code you may also want to check `authWithOAuth2` method.

On success, this method also automatically updates the client's AuthStore data and returns: - the authentication token via the model - the authenticated record model - the OAuth2 account data (eg. name, email, avatar, etc.)

func (*Collection[T]) AuthWithPassword

func (c *Collection[T]) AuthWithPassword(username string, password string) (AuthWithPasswordResponse, error)

AuthWithPassword authenticate a single auth collection record via its username/email and password.

On success, this method also automatically updates the client's AuthStore data and returns: - the authentication token via the AuthWithPasswordResponse - the authenticated record model

func (*Collection[T]) ConfirmEmailChange

func (c *Collection[T]) ConfirmEmailChange(emailChangeToken string, password string) error

ConfirmEmailChange confirms auth record's new email address.

func (*Collection[T]) ConfirmPasswordReset

func (c *Collection[T]) ConfirmPasswordReset(passwordResetToken string, password string, passwordConfirm string) error

ConfirmPasswordReset confirms auth record password reset request.

func (*Collection[T]) ConfirmVerification

func (c *Collection[T]) ConfirmVerification(verificationToken string) error

ConfirmVerification confirms auth record email verification request.

If the current `client.authStore.model` matches with the auth record from the token, then on success the `client.authStore.model.verified` will be updated to `true`.

func (*Collection[T]) Create

func (c *Collection[T]) Create(body T) (ResponseCreate, error)

Create creates a new record in the collection.

func (*Collection[T]) Delete

func (c *Collection[T]) Delete(id string) error

Delete removes a record from the collection by ID.

func (*Collection[T]) FullList

func (c *Collection[T]) FullList(params ParamsList) (ResponseList[T], error)

FullList retrieves all records from the collection without pagination.

func (*Collection[T]) List

func (c *Collection[T]) List(params ParamsList) (ResponseList[T], error)

List retrieves a paginated list of records from the collection.

func (*Collection[T]) ListAuthMethods

func (c *Collection[T]) ListAuthMethods() (AuthMethodsResponse, error)

ListAuthMethods returns all available collection auth methods.

func (*Collection[T]) ListAuthMethods22

func (c *Collection[T]) ListAuthMethods22() (AuthMethod, error)

ListAuthMethods22 returns all available collection auth methods (legacy version).

func (*Collection[T]) ListExternalAuths22

func (c *Collection[T]) ListExternalAuths22(recordID string) ([]ExternalAuthRequest, error)

ListExternalAuths22 lists all linked external auth providers for the specified auth record.

func (*Collection[T]) One

func (c *Collection[T]) One(id string) (T, error)

One retrieves a single record from the collection by ID.

func (*Collection[T]) OneWithParams

func (c *Collection[T]) OneWithParams(id string, params ParamsList) (T, error)

OneWithParams retrieves a single record from the collection by ID with additional parameters. Only fields and expand parameters are supported.

func (*Collection[T]) RequestEmailChange

func (c *Collection[T]) RequestEmailChange(newEmail string) error

RequestEmailChange sends an email change request to the authenticated record model.

func (*Collection[T]) RequestPasswordReset

func (c *Collection[T]) RequestPasswordReset(email string) error

RequestPasswordReset sends auth record password reset request

func (*Collection[T]) RequestVerification

func (c *Collection[T]) RequestVerification(email string) error

RequestVerification sends auth record verification email request.

func (*Collection[T]) Subscribe

func (c *Collection[T]) Subscribe(targets ...string) (*Stream[T], error)

Subscribe creates a real-time subscription to the collection with default options.

func (*Collection[T]) SubscribeWith

func (c *Collection[T]) SubscribeWith(opts SubscribeOptions, targets ...string) (*Stream[T], error)

SubscribeWith creates a real-time subscription with custom options and target collections.

func (*Collection[T]) UnlinkExternalAuth22

func (c *Collection[T]) UnlinkExternalAuth22(recordID string, provider string) error

UnlinkExternalAuth22 unlinks a single external auth provider from the specified auth record.

func (*Collection[T]) Update

func (c *Collection[T]) Update(id string, body T) error

Update updates a record in the collection with the specified ID.

type CreateRequest

type CreateRequest struct {
	Name string `json:"name"`
}

CreateRequest represents the request structure for creating a backup.

type Event

type Event[T any] struct {
	Action string `json:"action"`
	Record T      `json:"record"`
	Error  error  `json:"-"`
}

Event represents a real-time event from PocketBase with action, record data, and optional error.

type ExternalAuthRequest

type ExternalAuthRequest struct {
	ID           string `json:"id"`
	Created      string `json:"created"`
	Updated      string `json:"updated"`
	RecordID     string `json:"recordId"`
	CollectionID string `json:"collectionId"`
	Provider     string `json:"provider"`
	ProviderID   string `json:"providerId"`
}

ExternalAuthRequest represents an external authentication provider link.

type Files

type Files struct {
	*Client
}

Files provides methods for managing PocketBase file operations.

func (Files) GetToken

func (f Files) GetToken() (string, error)

GetToken requests a new private file access token for the current auth model (admin or record).

type ParamsList

type ParamsList struct {
	Page    int
	Size    int
	Filters string
	Sort    string
	Expand  string
	Fields  string
	// contains filtered or unexported fields
}

ParamsList represents query parameters for PocketBase API requests including pagination, filtering, and sorting.

type Record

type Record struct {
	Avatar          string `json:"avatar"`
	CollectionID    string `json:"collectionId"`
	CollectionName  string `json:"collectionName"`
	Created         string `json:"created"`
	Email           string `json:"email"`
	EmailVisibility bool   `json:"emailVisibility"`
	ID              string `json:"id"`
	Name            string `json:"name"`
	Updated         string `json:"updated"`
	Username        string `json:"username"`
	Verified        bool   `json:"verified"`
}

Record represents a PocketBase record with common fields.

type ResponseBackupFullList

type ResponseBackupFullList struct {
	Key      string `json:"key"`
	Size     int    `json:"size"`
	Modified string `json:"modified"`
}

ResponseBackupFullList represents a backup file in the backup list response.

type ResponseCreate

type ResponseCreate struct {
	ID      string `json:"id"`
	Created string `json:"created"`
	Field   string `json:"field"`
	Updated string `json:"updated"`
}

ResponseCreate represents the response from creating a new record.

type ResponseGetToken

type ResponseGetToken struct {
	Token string `json:"token"`
}

ResponseGetToken represents the response from requesting a file access token.

type ResponseList

type ResponseList[T any] struct {
	Page       int `json:"page"`
	PerPage    int `json:"perPage"`
	TotalItems int `json:"totalItems"`
	TotalPages int `json:"totalPages"`
	Items      []T `json:"items"`
}

ResponseList represents a paginated list response from PocketBase.

type Stream

type Stream[T any] struct {
	// contains filtered or unexported fields
}

Stream represents a real-time event stream with subscription management capabilities.

func (*Stream[T]) Events

func (s *Stream[T]) Events() <-chan Event[T]

Events returns a channel that receives real-time events from the stream.

func (*Stream[T]) Ready

func (s *Stream[T]) Ready() <-chan struct{}

Ready returns a channel that closes when the stream is ready to receive events.

func (*Stream[T]) Unsubscribe

func (s *Stream[T]) Unsubscribe()

Unsubscribe closes the stream and cleans up resources.

func (*Stream[T]) WaitAuthReady

func (s *Stream[T]) WaitAuthReady() error

WaitAuthReady waits for the stream to be ready for authentication. Deprecated: use <-stream.Ready() instead.

type SubscribeOptions

type SubscribeOptions struct {
	ReconnectStrategy backoff.BackOff
}

SubscribeOptions configures real-time subscription behavior including reconnection strategy.

type SubscriptionsSet

type SubscriptionsSet struct {
	ClientID      string   `json:"clientId"`
	Subscriptions []string `json:"subscriptions"`
}

SubscriptionsSet represents the subscription configuration sent to PocketBase.

Directories

Path Synopsis
cmd
pocketbase command
Package main provides the PocketBase server executable.
Package main provides the PocketBase server executable.
Package main provides usage examples for the PocketBase Go SDK.
Package main provides usage examples for the PocketBase Go SDK.
Package migrations provides database migration scripts for PocketBase collections.
Package migrations provides database migration scripts for PocketBase collections.

Jump to

Keyboard shortcuts

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