Sample Header Ad - 728x90

Incorrect migration of an object from Firebase to MongoDB

0 votes
1 answer
231 views
I am in the process of migrating a database from Firebase to MongoDB and am facing a problem. Here is such an object I have stored in the FB:
-js
"logs": {
    "2021-05-24": {
        "124109": {
            "foo": "text",
            "bar": "text"
        }
    }
}
When I import it into Mongo (through the Mongo compass as a JSON object) it is inserted in this form:
-js
"logs": {
    "2021-05-24": [
        null,
        null,
        ... # overall 124109 nulls here
        null,
        {
            "foo": "text",
            "bar": "text"
        }
    ]
}
As I can see, it reads the key of the nested object as the number of real array objects. How can I correctly migrate an object of this type in mongo?
Asked by RoyalGoose (115 rep)
Sep 10, 2021, 07:22 PM
Last activity: Sep 13, 2021, 10:26 AM