Feature: Select Model without using Record-IDs
Is your feature request related to a problem?
Select a Model by using e.g. a Username instead of a Record ID
Describe the solution
i think it would be better to select a model by like using a username from a column instead to use a record id.
Alternative methods
I came to an idea to add something like a .where("key", "value") method to the end of driver.select(...) Example: User user = driver.select("table", User.class).where("key", "value"))
SurrealDB version
1.0.0-beta.9+20230402.5eafebd for windows on x86_64
Contact Details
No response
Is there an existing issue for this?
- [x] I have searched the existing issues
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
This is an interesting idea, although I think it's worth mentioning:
- You wouldn't be able to use the ws method for select (see: https://surrealdb.com/docs/integration/websocket/text#select)
- The
selectfunction doesn't return a builder but a result of the select, I think it would have to look something like this:
driver.selectBuilder(...).where(...).where(...).execute()
- I think you'd have to pass the class of the element into the where function similar to
select:
...
.where("key", "value", String.class)
.where("user_details", new UserDetails("[email protected]", 25), UserDetails.class)
With version 0.2.0, the select method now has several variants, allowing for the selection of a table. https://surrealdb.github.io/surrealdb.java/javadoc/com/surrealdb/Surreal.html#select(java.lang.Class,java.lang.String)