-
Notifications
You must be signed in to change notification settings - Fork 66
/
types.go
62 lines (52 loc) · 1.52 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package surrealdb
import (
"github.com/fxamacker/cbor/v2"
"github.com/surrealdb/surrealdb.go/internal/codec"
"github.com/surrealdb/surrealdb.go/pkg/constants"
"github.com/surrealdb/surrealdb.go/pkg/models"
)
// Patch represents a patch object set to MODIFY a record
type PatchData struct {
Op string `json:"op"`
Path string `json:"path"`
Value any `json:"value"`
}
type QueryResult[T any] struct {
Status string `json:"status"`
Time string `json:"time"`
Result T `json:"result"`
}
type QueryStmt struct {
unmarshaler codec.Unmarshaler
SQL string
Vars map[string]interface{}
Result QueryResult[cbor.RawMessage]
}
func (q *QueryStmt) GetResult(dest interface{}) error {
if q.unmarshaler == nil {
return constants.ErrNoUnmarshaler
}
return q.unmarshaler.Unmarshal(q.Result.Result, dest)
}
type Relationship struct {
ID *models.RecordID `json:"id"`
In models.RecordID `json:"in"`
Out models.RecordID `json:"out"`
Relation models.Table `json:"relation"`
Data map[string]any `json:"data"`
}
// Auth is a struct that holds surrealdb auth data for login.
type Auth struct {
Namespace string `json:"NS,omitempty"`
Database string `json:"DB,omitempty"`
Scope string `json:"SC,omitempty"`
Username string `json:"user,omitempty"`
Password string `json:"pass,omitempty"`
}
type Obj map[interface{}]interface{}
type Result[T any] struct {
T any
}
type TableOrRecord interface {
string | models.Table | models.RecordID | []models.Table | []models.RecordID
}