JS script for bulk uploading to Google Cloud Firestone not working as expected

Hello all! We are looking for ways to bulk upload data into google firestore and found an awesome script to do so, sort of. The problem is that when data is uploaded the collection is fine, document is fine, but nesting some data we can only manage to import as “map” type when we need “array” and “map”. Since we are basically newbies trial and error has not been enough. We appreciate if you can take a look at the code and help us with that.

So far, with the following code:

<!DOCTYPE html>

    <meta charset="utf-8">
    <script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-firestore.js"></script>


        var config = {
            apiKey: 'MY API KEY',
            authDomain: 'MY AUTHDOMAIN',
            projectId: 'MY PROJECT ID'

        var firestore = firebase.firestore();

        //Paste from the CSV to JSON converter
        const data = [
                "collection": "sub_cats",
                "uid": "Av9vJ0EoFfxhAR2",
                "class": "especialidades_medicas",
                "id": 0,
                "name": "Cardiologo",
                "ind": "11",
                "district": ""
                "collection": "sub_cats",
                "uid": "Av9vJ0EoFfxhAR2",
                "class": "especialidades_medicas",
                "id": 1,
                "name": "Urologo",
                "ind": "12",
                "district": ""

        var promises = [];
		data.forEach(function (arrayItem) {
        var docRef = firestore.collection(arrayItem.collection).doc(arrayItem.uid);
        var objClass = {};
        var objId = {};
        objId[arrayItem.id] = { name: arrayItem.name, ind: arrayItem.ind };
        objClass[arrayItem.class] = objId;

        promises.push(docRef.set(objClass, { merge: true }));



we get this:

How would you modify this code to get the array / map structure?

Thanks a lot!!!

I know nothing about firestore,. but when I looked at the documentation, it seems you are deviating from the instructions.

For NoSQL I use Redis.

At a quick glance it looks like this line:

 objId[arrayItem.id] = { name: arrayItem.name, ind: arrayItem.ind };

it setting objectId[arrayItem.id] to an object, which is why you see a map and map.

Its hard to tell though due to the naming conventions being really vague and not actually matching the firebase data in the screenshots.