Documentation
¶
Index ¶
- Constants
- type AuthArgs
- type Connection
- type DB
- func (db *DB) Authenticate(token string) error
- func (db *DB) Close() error
- func (db *DB) Create(table string, data any, destination ...any) error
- func (db *DB) Delete(id string, destination ...any) error
- func (db *DB) Info(destination any) error
- func (db *DB) Insert(table string, data any, destination ...any) error
- func (db *DB) Invalidate() error
- func (db *DB) Kill(id string) error
- func (db *DB) Let(identifier string, value any) error
- func (db *DB) Live(id string, callback func(notification rpc.LiveNotification), diff bool) (string, error)
- func (db *DB) Merge(id string, data any, destination ...any) error
- func (db *DB) Patch(id string, diff []Diff, destination ...any) error
- func (db *DB) Ping() error
- func (db *DB) Query(query string, vars Map, scanDestinations ...any) error
- func (db *DB) Relate(from any, thing string, to any, data any, destination ...any) error
- func (db *DB) Select(id string, destination any) error
- func (db *DB) SignIn(args AuthArgs) error
- func (db *DB) SignUp(args AuthArgs) error
- func (db *DB) Unset(identifier string) error
- func (db *DB) Update(id string, data any, destination ...any) error
- func (db *DB) Upsert(id string, data any, destination ...any) error
- func (db *DB) Use(namespace, databaseName string) error
- func (db *DB) Version() (string, error)
- type Diff
- type LiveDiff
- type Map
- type Options
- type QueryError
- type QueryErrors
- type WebSocketConnection
- type WebSocketOptions
Constants ¶
const ( Alphanumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" DefaultTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthArgs ¶
type AuthArgs struct {
Namespace string `json:"NS"`
Database string `json:"DB"`
Scope string `json:"SC,omitempty"`
Access string `json:"AC,omitempty"`
Other Map `json:"-"`
}
func (AuthArgs) MarshalJSON ¶
type Connection ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Authenticate ¶
func (*DB) Create ¶
Create creates a record in a table, then decodes the row into the destination, if provided. Destination may be either a pointer to a slice or a pointer to a single record (struct, map).
func (*DB) Delete ¶
Delete deletes a record, or all records, from a table, then decodes the rows into the destination, if provided.
func (*DB) Insert ¶
Insert inserts a record, or multiple records, into a table, then decodes the rows into the destination, if provided. Destination may be either a pointer to a slice or a pointer to a single record (struct, map).
func (*DB) Invalidate ¶
func (*DB) Query ¶
Query sends a query (or multiple semicolon separated queries) to the database and returns the result (results). The result is decoded into the scanDestinations. If there are multiple queries, the results are decoded into the corresponding scanDestinations. `vars` is a map of variables that are used to bind the query (or queries).
func (*DB) Select ¶
Select performs a select query and decodes the results into the destination. May target a single record or all records in a table. Returns error if id is not a table name and there is no row found.
type LiveDiff ¶ added in v0.0.3
type LiveDiff struct {
Op string `json:"op"`
Path string `json:"path"`
Value json.RawMessage `json:"value"`
}
type Options ¶
type Options struct {
Verbose bool
WebSocketOptions WebSocketOptions
}
type QueryError ¶
type QueryErrors ¶
type QueryErrors []QueryError
func (QueryErrors) Error ¶
func (q QueryErrors) Error() string
type WebSocketConnection ¶
type WebSocketConnection struct {
// contains filtered or unexported fields
}
func (*WebSocketConnection) Close ¶
func (ws *WebSocketConnection) Close() error
func (*WebSocketConnection) RegisterLiveCallback ¶ added in v0.0.3
func (ws *WebSocketConnection) RegisterLiveCallback(event string, callback func(notification rpc.LiveNotification))
func (*WebSocketConnection) Run ¶
func (ws *WebSocketConnection) Run()
type WebSocketOptions ¶
type WebSocketOptions struct {
// DisableCompression enables compression for the websocket connection.
DisableCompression bool
// OnDropCallback is called when the websocket connection is dropped.
OnDropCallback func(reason error)
// ResponseTimeout is the duration to wait for a response before timing out. Defaults to 10 seconds.
ResponseTimeout time.Duration
}