Open dsidharta opened 2 years ago
I'm not sure that it will be correct from the data correctness side.
Now you can for example "delete/undelete" related Y entities or count them in your code like x.xy.forEach { it.deleted = false }
but if you'll filter that relation you wont be able to do that.
Why don't delete relation in XY when mark X or Y as deleted?
Why don't delete relation in XY when mark X or Y as deleted?
Ideally, we want to preserve the relationships for various purposes, e.g. audit and various other use cases.
Now you can for example "delete/undelete" related Y entities or count them in your code like x.xy.forEach { it.deleted = false } but if you'll filter that relation you wont be able to do that.
Yep, valid thought, and thus my original question of the conditionality of the fetching because if we can conditionally fetch, I think this won't be a problem. Thanks!
Don't know if this helps, but here is related functionality in another library. Would be nice to see the possibility to do something similar.
@dsidharta did you find any solution, please share with us
@mdsadiqueinam, no I didn't find any solutions, but I happened to be changing my model at the same time, and so this was no longer an issue for me.
Is there a way to specify a condition of eager loading when using
with()
? For example, we have a field signifying a soft-deleted row:deleted
; is there a way to specify that we don't want to eager-fetch rows whosedeleted = 't'
?Without any conditions, we can eager-load easily as follows:
But is there a way to specify that we want
XY.deleted = 'f'
andY.deleted = 'f'
? I've tried something like the following, but this doesn't eager-load the relationships, i.e. accessing eachX.ys
generates a select query.