Documentation ¶
Index ¶
- Variables
- func ChangeAs[T any](ctx *context.Context, db *DB, what string, data any) (*T, error)
- func CreateAs[T any](ctx *context.Context, db *DB, thing string, data any) (*T, error)
- func ModifyAs[T any](ctx *context.Context, db *DB, what string, data []Patch) (*T, error)
- func QueryAs[T any](ctx *context.Context, db *DB, sql string, vars any) (*T, error)
- func SelectAs[T any](ctx *context.Context, db *DB, what string) (*T, error)
- func UpdateAs[T any](ctx *context.Context, db *DB, what string, data any) (*T, error)
- type DB
- func (db *DB) Authenticate(ctx *context.Context, token string) error
- func (db *DB) Change(ctx *context.Context, what string, data interface{}) *SurrealWSResult
- func (db *DB) Close() error
- func (db *DB) Create(ctx *context.Context, thing string, data interface{}) *SurrealWSResult
- func (db *DB) Delete(ctx *context.Context, what string) error
- func (db *DB) Info(ctx *context.Context) error
- func (db *DB) Invalidate(ctx *context.Context) error
- func (db *DB) Kill(ctx *context.Context, query string) error
- func (db *DB) Let(ctx *context.Context, key string, val interface{}) error
- func (db *DB) Live(ctx *context.Context, table string) error
- func (db *DB) Modify(ctx *context.Context, what string, data []Patch) *SurrealWSResult
- func (db *DB) Query(ctx *context.Context, sql string, vars interface{}) *SurrealWSRawResult
- func (db *DB) Select(ctx *context.Context, what string) *SurrealWSResult
- func (db *DB) Signin(ctx *context.Context, vars UserInfo) error
- func (db *DB) Signup(ctx *context.Context, vars interface{}) error
- func (db *DB) Update(ctx *context.Context, what string, data interface{}) *SurrealWSResult
- func (db *DB) Use(ctx *context.Context, ns string, dbname string) error
- type ErrFailedRawQuery
- type ErrFailedUnmarshal
- type ErrInvalidSurrealResponse
- type MultiQueryError
- type Patch
- type RPCError
- type RPCNotification
- type RPCRequest
- type RPCResponse
- type RawRPCResponse
- type SurrealWSRawResult
- type SurrealWSResult
- type UserInfo
- type WS
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a client for the SurrealDB database that holds are websocket connection.
func (*DB) Change ¶
func (db *DB) Change(ctx *context.Context, what string, data interface{}) *SurrealWSResult
Change a table or record in the database like a PATCH request.
func (*DB) Create ¶
func (db *DB) Create(ctx *context.Context, thing string, data interface{}) *SurrealWSResult
Create a table or record in the database like a POST request.
func (*DB) Query ¶
func (db *DB) Query(ctx *context.Context, sql string, vars interface{}) *SurrealWSRawResult
Query is a convenient method for sending a query to the database.
func (*DB) Select ¶
func (db *DB) Select(ctx *context.Context, what string) *SurrealWSResult
Select a table or record from the database.
type ErrFailedRawQuery ¶ added in v1.0.6
type ErrFailedRawQuery struct {
Cause error
}
func (ErrFailedRawQuery) Error ¶ added in v1.0.6
func (e ErrFailedRawQuery) Error() string
type ErrFailedUnmarshal ¶ added in v1.0.6
type ErrFailedUnmarshal struct {
Cause error
}
func (ErrFailedUnmarshal) Error ¶ added in v1.0.6
func (e ErrFailedUnmarshal) Error() string
type ErrInvalidSurrealResponse ¶ added in v1.0.6
type ErrInvalidSurrealResponse struct {
Cause error
}
func (ErrInvalidSurrealResponse) Error ¶ added in v1.0.6
func (e ErrInvalidSurrealResponse) Error() string
type MultiQueryError ¶ added in v1.0.6
type Patch ¶ added in v1.0.6
type Patch struct { Op string `json:"op"` Path string `json:"path"` Value interface{} `json:"value"` }
Patch represents a patch object set to MODIFY a record
type RPCError ¶
type RPCError struct { Code int `json:"code" msgpack:"code"` Message string `json:"message,omitempty" msgpack:"message,omitempty"` }
RPCError represents a JSON-RPC error
type RPCNotification ¶
type RPCNotification struct { ID interface{} `json:"id" msgpack:"id"` Method string `json:"method,omitempty" msgpack:"method,omitempty"` Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"` }
RPCNotification represents an outgoing JSON-RPC notification
type RPCRequest ¶
type RPCRequest struct { ID interface{} `json:"id" msgpack:"id"` Async bool `json:"async,omitempty" msgpack:"async,omitempty"` Method string `json:"method,omitempty" msgpack:"method,omitempty"` Params []interface{} `json:"params,omitempty" msgpack:"params,omitempty"` }
RPCRequest represents an incoming JSON-RPC request
type RPCResponse ¶
type RPCResponse struct { ID interface{} `json:"id" msgpack:"id"` Error *RPCError `json:"error,omitempty" msgpack:"error,omitempty"` Result interface{} `json:"result,omitempty" msgpack:"result,omitempty"` }
RPCResponse represents an outgoing JSON-RPC response
type RawRPCResponse ¶ added in v1.0.6
RawRPCResponse represents an outgoing JSON-RPC response
type SurrealWSRawResult ¶ added in v1.0.6
func (SurrealWSRawResult) String ¶ added in v1.0.6
func (r SurrealWSRawResult) String() string
func (*SurrealWSRawResult) Unmarshal ¶ added in v1.0.6
func (r *SurrealWSRawResult) Unmarshal(v interface{}) error
Unmarshal unmarshals a single response returned by a raw query
func (*SurrealWSRawResult) UnmarshalMultiQuery ¶ added in v1.0.6
func (r *SurrealWSRawResult) UnmarshalMultiQuery(v ...interface{}) []MultiQueryError
UnmarshalMultiQuery unmarshals the response returned by queries sent in bulk into the provided containers.
type SurrealWSResult ¶ added in v1.0.6
func (SurrealWSResult) String ¶ added in v1.0.6
func (r SurrealWSResult) String() string
func (*SurrealWSResult) Unmarshal ¶ added in v1.0.6
func (r *SurrealWSResult) Unmarshal(v interface{}) error