Feature: Query builder like syntax
letto4135 opened this issue · comments
Is your feature request related to a problem?
Inflexible sdks.
The query method allows the execution of arbitrary SQL at the expense of a typed return, and the select method is extremely rigid in what it does but it does have a typed return.
Describe the solution
Query builder like syntax to combine the best of both worlds.
Nothing needs to change on what is there already, but new methods could be added that can be chained together to build a query and then completed with a call to a particular method such as fetch
.
let res Vec<Model> = db.from('table').filter('column', 'eq', 'value').order_by('column2').limit(10).fetch().await?
I'm not entirely sure, but potentially fetch
could even discern the SELECT
portion of the statement from they type its returning? Potentially through something like fetch<Model>()
?
Alternative methods
Only alternatives are query for EVERYTHING or handle the generic surrealdb::Response
from query
with let created: Option<Person> = result.take(0)?;
off of query result which is a good way to do it, but the potential for a set of simple query builder methods is more succinct
SurrealDB version
1.4.2 for macos on aarch64
Contact Details
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct