-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Use a raw query? #383
Comments
Hi Ingwie, you can run raw query just like this: sql := rel.SQL("SELECT id, title, price, orders = (SELECT COUNT(t.id) FROM [transactions] t WHERE t.book_id = b.id) FROM books b where b.id=?", 1)
err := repo.Find(ctx, &book, sql) |
Great, thank you! Must've not seen the forest for all it's trees... Last thing: Is there a better way to stringify generated queries? In my tests, I'd like to verify if my SQL generates correctly. Currently, I just cast the
Is there a more elegant solution rather than casting directly to the adapter type? I couldn't find a direct function for that in the interface. By the way, the driver is here: https://github.com/IngwiePhoenix/surrealdb-driver/blob/master/pkg/rel/ - I have a lot of test cases to write yet, but this was implemented in but a day, which was quite easy to do actually. Thanks and kind regards! |
the query builder is an internal adapter implementation right now, so there's no direct way to access it from rel as of now |
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.
Is there an easier way to construct raw queries? I can't imagine it's this convoluted... x)
Kind regards,
Ingwie
The text was updated successfully, but these errors were encountered: