A problem about manipulating DBRef data during anlyzing mongodb data through python

42 Views Asked by At

I'm working with MongoDB and want to analyze the extracted data from this database by python to visualize required information.Two question arises: 1) in such data there is DBRef that I don't know how to manipulate it, 2) it seems that is a nested data and needs to be broken to lowe level! 3) can I covert DBref to JSON file and the analyze it?

Thanks guys

1

There are 1 best solutions below

0
On

Have a look at this.

This allows you to essentially "unpack" the DBRef and retrieve only the id's, if that is of any use to you.

Example:

x = {
    "oId": 567,
    "notice": [
        DBRef("noticeId", ObjectId("5f45177b93d7b757bcbd2d55"))
    ]
}
print(x.get('oId'), d.get('notice')[0].id)