jloosli / node-firestore-import-export

Firestore data import and export
https://www.npmjs.com/package/node-firestore-import-export
MIT License
392 stars 79 forks source link

importing document references shows as an object #12

Closed mcconkiee closed 6 years ago

mcconkiee commented 6 years ago

Expected behavior

After import, document references should be proper firestore references

expected

Actual behavior

After import, reference objects are actually key/values object representations of their export object 2

Steps to reproduce the behavior

  1. export firestore db using the firestore export.js file
  2. import the backup file produced in step 1 back to the db
  3. All references are simply POJOs (JSON)
jloosli commented 6 years ago

Which version of the module are you using? This should have been fixed in v0.7.0. Can you double check that and if it's not updated, try updating and running again?

mcconkiee commented 6 years ago

package reads "version": "1.0.0",

mcconkiee commented 6 years ago

sorry. that's 0.6.5 - let me updaet

mcconkiee commented 6 years ago

ok, i updated and tried again └── node-firestore-import-export@0.7.1 however, I am still having the same issue

jloosli commented 6 years ago

Strange. In a test document I have, the console looks like the following (tried to name field names the same as their type):

screenshot-console firebase google com-2018 03 28-14-46-10

The resulting export looks like the following (with geopoint, timestamp, and documentReference converted to a json-friendly format):

{
  "h4QbyGCocxgg1kJu823S": {
    "timestamp": {
      "__datatype__": "timestamp",
      "value": "2018-03-27T14:02:03.000Z"
    },
    "georeference": {
      "__datatype__": "geopoint",
      "value": {
        "_latitude": 12.15715,
        "_longitude": -158.2351784
      }
    },
    "string": "string",
    "boolean": true,
    "object": {
      "name": "object",
      "timestamp": {
        "__datatype__": "timestamp",
        "value": "2018-03-21T13:23:12.000Z"
      }
    },
    "number": 12351.342,
    "array": {
      "0": 1,
      "1": {
        "__datatype__": "timestamp",
        "value": "2018-03-27T18:23:23.000Z"
      }
    },
    "reference": {
      "__datatype__": "documentReference",
      "value": "organizations/oakley"
    },
    "__collections__": {}
  }
}

The document reference should look something like

{
  "field": {
    "__datatype__": "documentReference",
    "value": "organizations/oakley"
  }
}

Do you have any timestamp or geopoint fields that don't convert either? What happens if you pass the -V flag to the command? Is that showing 0.7.1 as well?

mcconkiee commented 6 years ago

@jloosli - completely appropriate you getting me back up - total version problem. Makes sense i think. I had exported w/ the old version and tried to import with the current. Doing a full retry with just the current solves my problem.

THANKS

jloosli commented 6 years ago

Wonderful. Glad it's working for you. Let me know if you run into other problems

jefelewis commented 5 years ago

Is it possible to specify the datatype when importing? Specifically, GeoPoints?