How to import CSV or JSON to firebase cloud firestore

前端 未结 11 1038
星月不相逢
星月不相逢 2020-11-29 16:19

Is there a way to import CSV or JSON to firebase cloud firestore like in firebase realtime database?

11条回答
  •  攒了一身酷
    2020-11-29 17:01

    This is a small modification that copies the 'id' of the document, if exists, to its path. Otherwise it will use the "for"'s index.

      ...
      ...
      } else {
        // Collection's length of is always odd.
        for (const key in data) {
          // Resolve each collection.
          if (data[key]['id']!==undefined)
            await resolve(data[key], [...path,data[key]['id']])
          else 
            await resolve(data[key], [...path, key]);
        }
      }
    }
    
    resolve(data);
    

提交回复
热议问题