OpenDevUFCG / laguinho-api

Onde todos os dados, pessoas e radiação da UFCG se encontram.
MIT License
28 stars 18 forks source link

Use mongo projection to remove _id from responses #70

Open MarioHdpz opened 5 years ago

MarioHdpz commented 5 years ago

Enhancement proposal for issue #69

Mongo allow us to select the fields we're retreiving by providing a second argument (projection).

So I added the projection {_id: 0} to prevent that field to appear in responses instead of deleting it from the response.

One interesting thing is that the insert_one method from PyMongo was modifying the input we were providing, so I prevent this mutation by providing a copy of the result dictionary.

Hope it helps!