Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to only keep the data I want after retrieving data from mongodb

mydoc = mycollection_Users.find_one( {}, { "Username": 0})

this is the code I wrote to get the password from MongoDB, when I put 0 in the search value it will give me all the values except Usernames’ value.
but I get the value like this

{'_id': ObjectId('618bc65e33c87d5cfbdd5a28'), 'Password': 'example'}

how can I only keep what the actual password is and remove everything else, the product should be just "example" and nothing else

Any help will be great, thx

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First convert the value into string and slice the text to get the password or put it in a variable and write password['Password']

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading