diff --git a/util/fncs/batch.go b/util/fncs/batch.go index 9ffea14a..1858e130 100644 --- a/util/fncs/batch.go +++ b/util/fncs/batch.go @@ -17,11 +17,19 @@ package fncs import ( "context" + "github.com/abcum/surreal/mem" "github.com/abcum/surreal/sql" ) func batch(ctx context.Context, args ...interface{}) (interface{}, error) { + tb, _ := ensureString(args[0]) id, _ := ensureSlice(args[1]) + + if len(tb) == 0 { + return nil, mem.ErrorTBNotFound + } + return sql.NewBatch(tb, id), nil + } diff --git a/util/fncs/model.go b/util/fncs/model.go index 99ec4372..241d9896 100644 --- a/util/fncs/model.go +++ b/util/fncs/model.go @@ -17,11 +17,18 @@ package fncs import ( "context" + "github.com/abcum/surreal/mem" "github.com/abcum/surreal/sql" ) func model(ctx context.Context, args ...interface{}) (interface{}, error) { + tb, _ := ensureString(args[0]) + + if len(tb) == 0 { + return nil, mem.ErrorTBNotFound + } + switch len(args) { case 2: if max, ok := ensureFloat(args[1]); ok { @@ -42,5 +49,7 @@ func model(ctx context.Context, args ...interface{}) (interface{}, error) { } } } + return nil, nil + } diff --git a/util/fncs/table.go b/util/fncs/table.go index 61d09059..d7a39fda 100644 --- a/util/fncs/table.go +++ b/util/fncs/table.go @@ -17,10 +17,18 @@ package fncs import ( "context" + "github.com/abcum/surreal/mem" "github.com/abcum/surreal/sql" ) func table(ctx context.Context, args ...interface{}) (interface{}, error) { + tb, _ := ensureString(args[0]) + + if len(tb) == 0 { + return nil, mem.ErrorTBNotFound + } + return sql.NewTable(tb), nil + } diff --git a/util/fncs/thing.go b/util/fncs/thing.go index 9f233c84..abbd5023 100644 --- a/util/fncs/thing.go +++ b/util/fncs/thing.go @@ -17,10 +17,18 @@ package fncs import ( "context" + "github.com/abcum/surreal/mem" "github.com/abcum/surreal/sql" ) func thing(ctx context.Context, args ...interface{}) (interface{}, error) { + tb, _ := ensureString(args[0]) + + if len(tb) == 0 { + return nil, mem.ErrorTBNotFound + } + return sql.NewThing(tb, args[1]), nil + }