Skip to content

Docs: Use a raw query? #383

@IngwiePhoenix

Description

@IngwiePhoenix

I made my SurrealDB driver work and am currently testing it - and while testing the more "not so standart" parts of SurrealDB, I realized that... I had no idea how to run raw queries.

func main() {
	adapter, err := srel.Open("ws://root:root@127.0.0.1:8000/rpc?method=root")
	if err != nil {
		log.Fatal(err.Error())
	}
	defer adapter.Close()

	repo := rel.New(adapter)
	sql := rel.SQL("INFO FOR ROOT;")
	cursor, err := adapter.Query(context.TODO(), rel.Query{
		SQLQuery: sql,
	})
	if err != nil {
		log.Fatal(err.Error())
	}
	fields, err := cursor.Fields()
	if err != nil {
		log.Fatal(err.Error())
	}
	fmt.Print(fields)
}

Is there an easier way to construct raw queries? I can't imagine it's this convoluted... x)

Kind regards,
Ingwie

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions