Documentation ¶
Index ¶
- Variables
- func SmartMarshal[I any](inputfunc interface{}, data I) (output interface{}, err error)
- func SmartUnmarshal[I any](respond interface{}, wrapperError error) (data I, err error)
- func Unmarshal(data, v interface{}) error
- func UnmarshalRaw(rawData, v interface{}) (ok bool, err error)
- type Basemodel
- type DB
- func (db *DB) Authenticate(token string) (interface{}, error)
- func (db *DB) Change(what string, data interface{}) (interface{}, error)
- func (db *DB) Close()
- func (db *DB) Create(thing string, data interface{}) (interface{}, error)
- func (db *DB) Delete(what string) (interface{}, error)
- func (db *DB) Info() (interface{}, error)
- func (db *DB) Invalidate() (interface{}, error)
- func (db *DB) Kill(query string) (interface{}, error)
- func (db *DB) Let(key string, val interface{}) (interface{}, error)
- func (db *DB) Live(table string) (interface{}, error)
- func (db *DB) Modify(what string, data []Patch) (interface{}, error)
- func (db *DB) Query(sql string, vars interface{}) (interface{}, error)
- func (db *DB) Select(what string) (interface{}, error)
- func (db *DB) Signin(vars interface{}) (interface{}, error)
- func (db *DB) Signup(vars interface{}) (interface{}, error)
- func (db *DB) Update(what string, data interface{}) (interface{}, error)
- func (db *DB) Use(ns, database string) (interface{}, error)
- type Option
- type Patch
- type RawQuery
Constants ¶
This section is empty.
Variables ¶
var ( InvalidResponse = errors.New("invalid SurrealDB response") //nolint:stylecheck ErrQuery = errors.New("error occurred processing the SurrealDB query") ErrNoRow = errors.New("error no row") )
var ( ErrNotStruct = errors.New("data is not struct") ErrNotValidFunc = errors.New("invalid function") )
Smart Marshal Errors
Functions ¶
func SmartMarshal ¶ added in v0.2.0
SmartUnmarshal can be used with all DB methods with generics and type safety. This handles errors and can use any struct tag with `BaseModel` type. Warning: "ID" field is case sensitive and expect string. Upon failure, the following will happen 1. If there are some ID on struct it will fill the table with the ID 2. If there are struct tags of the type `Basemodel`, it will use those values instead 3. If everything above fails or the IDs do not exist, SmartUnmarshal will use the struct name as the table name.
func SmartUnmarshal ¶ added in v0.2.0
SmartUnmarshal using generics for return desired type. Supports both raw and normal queries.
func Unmarshal ¶ added in v0.2.0
func Unmarshal(data, v interface{}) error
Unmarshal loads a SurrealDB response into a struct.
func UnmarshalRaw ¶ added in v0.2.0
UnmarshalRaw loads a raw SurrealQL response returned by Query into a struct. Queries that return with results will return ok = true, and queries that return with no results will return ok = false.
Types ¶
type Basemodel ¶ added in v0.2.0
type Basemodel struct{}
Used for define table name, it has no value.
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) Authenticate ¶
func (*DB) Invalidate ¶
type Option ¶ added in v0.2.1
Option is a struct that holds options for the SurrealDB client.
func UseWriteCompression ¶ added in v0.2.1
UseWriteCompression enables or disables write compression for internal websocket client
func WithTimeout ¶ added in v0.2.1
WithTimeout sets the timeout for requests, default timeout is 30 seconds