I'm rather new to MongoDB, I can find some commands in shell to execute my query, however, I can not find a proper function in PyMongo API manual.
For example, I would like to project some of the fields of the document to a new document. I suppose the $project could do it, but there is no such support in Pymongo. How could I execute the same query both in shell and Python? For example:
db.books.aggregate( [ { $project : { title : 1 , author : 1 } } ] )
For projecting you may use the query as
db.books.aggregate([{'$project':{ 'title':'$title', 'author':'$author'}}])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With