Lazy Auto-population of fields option #329
pypoulp
started this conversation in
Feature Request
Replies: 1 comment
-
Wow. THis looks really interesting. I didn't think about such a feature. Thank you! I'll add this to the todo |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there,
First, thanks a lot for this amazing project ! I'm quite familiar with Python, not that much with Mongo, but it looks super easy with Beanie 😉.
I was thinking about Projections, and ways to optimize queries a bit. Some kind of lazy auto-population of fields could be great in some cases.
To explain, lets take an example from the docs:
find_one
just to update the price.Bar
object.I've used Ftrack Python API in the past, the default behavior is auto-population of fields, and you can use Projections to minimize the number of queries and fetch more data at once.
With the previous example, it may look a bit like:
So it's a bit like actual state managment, but with dynamic population of fields.
We can also think about a way to pass a Model to pre-fetch only some fields:
In a lot of cases, it's fine to get the full document and minimize the number of queries, but IMO this approach would be great when you just need to manipulate few fields of a large document.
Maybe I'm misunderstanding something and there is already a workaround to address this thing. Using Motor directly can be a solution.
I can try to prototype something, but I'd like to have your feedback before :)
Beta Was this translation helpful? Give feedback.
All reactions