-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch specific fields in a query #64
Comments
Yes, the beginning of an implementation has been done in #1 . class Rectangle(Model):
length: int
width: int
LengthView = createView(Rectangle, (Rectangle.length,))
# LengthView is a View object derived from pydantic; containing only the length field
rects = await engine.find(LengthView, Rectangle.width > 10) On top of this, since we are using mongodb view, it would be as well possible to do something like this: class RectangleAreaView(View, model=Rectangle):
area = Rectangle.length * Rectangle.width This would create a View containing a field computed (db side) from some other of its fields. |
Thank you so much |
Sorry, I don't get it!! where is the |
It's not there yet but it's in the plans :) |
Hello, any updates about this issue? This functionality is very promising I think |
I second this. I use this features in mongo/mongoose a lot. Would be a very nice feature to add. :) |
Any plan to implement this? |
We need it) |
Need it |
Protection queries are a particular type of MongoDB queries where you can specify fields you want to get in the output.
Another example where the projection parameter is used:
db.writers.find( { "author": "Gaurav Mandes" }, { _id:0, author:1, title:1 } )
In the example above, the _id field is excluded, which automatically gets added, and the title and author fields are displayed.
The text was updated successfully, but these errors were encountered: