Get all the values of a particular key

mongodb, mongodb-query, python, python-2.7

Solution

This Should Work

db.test.find({},{"category":1});

Problem

I have a data in mongoDB, I want to retrieve all the values of a key `"category"` using python code. I have tried several ways but in every case I have to give the "value" to retrieve. Any suggestions would be appreciated. ``` { id = "my_id1" tags: [tag1, tag2, tag3], category: "movie", }, { id = "my_id2" tags: [tag3, tag6, tag9], category: "tv", }, { id = "my_id3" tags: [tag2, tag6, tag8], category: "movie", } ``` I want the output as ``` category: "movie" category: "tv" category: "movie" ```

Original source