add libsql support

This commit is contained in:
xuu
2024-04-19 10:56:27 -06:00
parent 1f8b4ab24f
commit b1bff4cbf0
17 changed files with 609 additions and 248 deletions

View File

@@ -11,8 +11,8 @@ import (
type DbColumns struct {
Cols []string
index map[string]int
Table string
View string
Table string
View string
}
// Col returns the mapped column names
@@ -40,16 +40,16 @@ func GetDbColumns(o interface{}) *DbColumns {
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
sp := append(strings.Split(field.Tag.Get("db"), ","), "")
tag := sp[0]
tag, _, _ := strings.Cut(field.Tag.Get("db"), ",")
json := field.Tag.Get("json")
json, _, _ = strings.Cut(json, ",")
if tag == "" {
tag = json
}
graphql := field.Tag.Get("graphql")
graphql, _, _ = strings.Cut(graphql, ",")
if tag == "" {
tag = graphql
}
@@ -88,3 +88,11 @@ func GetDbColumns(o interface{}) *DbColumns {
}
return &d
}
func QuoteCols(cols []string) []string {
lis := make([]string, len(cols))
for i := range cols {
lis[i] = `"` + cols[i] + `"`
}
return lis
}