jloosli/node-firestore-import-export

firestoreImport() throws Cannot read property 'batch' of undefined

tohagan opened this issue · 1 comments

Expected behavior

firestoreImport() API should import a collection from an exported JSON file.

Actual behavior

firestoreImport() call failed with an exception

Steps to reproduce the behavior

  1. exported an "events" collection from an instance of Firestore.

  2. Running a unit test with ...
    const col = db.collection("events");
    const events = require("../../fixtures/events.json");
    await firestoreImport(col, events); // << throws TypeError: Cannot read property 'batch' of undefined

  3. In the debugger I found that ...
    This line in imports.ts executes const batch = startingRef.firestore.batch(); but startingRef.firestore is undefined.

My bad! Arguments were swapped.