Exists #730
Replies: 11 comments 3 replies
-
This would be useful indeed, I may take a look to implement this in the next few days. |
Beta Was this translation helpful? Give feedback.
-
How about adding a new operation let _: bool = Entity::find_by_id(1)
.exists(db)
.await?
let _: bool = Entity::find()
.filter( ... )
.exists(db)
.await? |
Beta Was this translation helpful? Give feedback.
-
I think it's good like this, just one thing that maybe you should take into account, when using the filter maybe there can be more than one, but when the filter is by id, it can only exist or not So maybe you can use |
Beta Was this translation helpful? Give feedback.
-
Btw... you could also |
Beta Was this translation helpful? Give feedback.
-
yes, I agree with what you said, but that would be one more call to the database that's why I talked about the filter returning the number of records, but it's just my opinion |
Beta Was this translation helpful? Give feedback.
-
🤔 Using the sql I thought this would be already implemented into sea-query but it's not. I guess this should be the starting point. Related to SeaQL/sea-query#118 |
Beta Was this translation helpful? Give feedback.
-
makes sense, and when I did that I didn't use this command, but looking at it from this side it only makes sense to return the boolean value |
Beta Was this translation helpful? Give feedback.
-
I am still thinking whether we should add the method to |
Beta Was this translation helpful? Give feedback.
-
I think it would be interesting to be separated as it doesn't have anything to do strictly with pagination, but something useful that can be used in any context. |
Beta Was this translation helpful? Give feedback.
-
I'm currently slowly switch a Ruby/ActiveRecord API to Rust and would love to see an |
Beta Was this translation helpful? Give feedback.
-
Can the |
Beta Was this translation helpful? Give feedback.
-
Add a variant of
find
, which checks if the record exists in the database but doesn't return any data, just says whether or not it existsThis improves performance in some cases where a test of whether the user has already been registered and the case will not be registered
There are better ways to do this test, which is in the insertion case of failure, check the error code, but as it is not so easy at the moment to obtain this code, it would be easier to implement this function
Beta Was this translation helpful? Give feedback.
All reactions