Skip to content
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

Feature: Query builder like syntax #4004

Open
2 tasks done
letto4135 opened this issue May 8, 2024 · 0 comments
Open
2 tasks done

Feature: Query builder like syntax #4004

letto4135 opened this issue May 8, 2024 · 0 comments
Labels
feature New feature or request topic:rust This is related to the Rust embedded library

Comments

@letto4135
Copy link

letto4135 commented May 8, 2024

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

[email protected]

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
@letto4135 letto4135 added feature New feature or request triage This issue is new labels May 8, 2024
@tobiemh tobiemh added topic:rust This is related to the Rust embedded library and removed triage This issue is new labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request topic:rust This is related to the Rust embedded library
Projects
None yet
Development

No branches or pull requests

2 participants