You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for creating this project, it has been fantastic to work with. I have a feature request, which I am happy to implement, I would like the find, find_many, find_all to project our model so that we get back only the data we are interested in.
This helps reduce database load.
An example of where we might use this is when we have a database model which hold a whole bunch of data, but we are loading a summary view which only requires 2 or 3 of these fields.
I am happy to implement this, I would do it by updating the find calls:
# get the field list of interest, this could be generated# at the __init__ stage and be stored in memory to prevent# having to build this many timesfields=test.__fields__projection= {}
forname, fieldinfields.items():
iffield.alias:
projection[field.alias] =1else:
projection[name] =1cursor=cls.get_motor_collection().find(filter_query, projection, **kwargs)
Let me know your thoughts and I can put together a PR next week
The text was updated successfully, but these errors were encountered:
First of all, thanks for creating this project, it has been fantastic to work with. I have a feature request, which I am happy to implement, I would like the find, find_many, find_all to project our model so that we get back only the data we are interested in.
This helps reduce database load.
An example of where we might use this is when we have a database model which hold a whole bunch of data, but we are loading a summary view which only requires 2 or 3 of these fields.
example:
I am happy to implement this, I would do it by updating the find calls:
Let me know your thoughts and I can put together a PR next week
The text was updated successfully, but these errors were encountered: