Documentation
¶
Index ¶
- Constants
- Variables
- func SmartMarshal[I any](inputfunc interface{}, data I) (output interface{}, err error)
- func SmartUnmarshal[I any](respond interface{}, out *I) error
- func Unmarshal(data, v interface{}) (err error)
- func UnmarshalRaw[I any](rawData interface{}, v *[]RawQuery[I]) (err error)
- type Basemodel
- type RawQuery
Constants ¶
const StatusOK = "OK"
Variables ¶
var ( ErrNotStruct = errors.New("data is not struct") ErrNotValidFunc = errors.New("invalid function") )
Smart Marshal Errors
Functions ¶
func SmartMarshal ¶
Smartmarshal 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 ¶
SmartUnmarshal using generics for return desired type. Supports both raw and normal queries.
func Unmarshal ¶
func Unmarshal(data, v interface{}) (err error)
Unmarshal loads a SurrealDB response into a struct.
func UnmarshalRaw ¶
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.