codediodeio / firestore-migrator

:bullettrain_side: A CLI utility for moving data to and from Cloud Firestore
https://angularfirebase.com/lessons/import-csv-json-or-excel-to-firestore/
317 stars 94 forks source link

Date import #13

Open aknuth opened 6 years ago

aknuth commented 6 years ago

exporting a Date/Timestamp Field from Firebase lead to e.g. an {"start":"2018-08-26T12:00:00.000Z"} and vice versa importing this into firebase marks this field as string ... does the script excepts any other date pattern ? or is this a bug ?

stildalf commented 6 years ago

Hi @aknuth, you're right, in it's current form. There is a waiting pull request which sorts this out for Timestamp and the other Firestore types such as Geopoint, Doc Reference, etc.

aknuth commented 6 years ago

thanks for your quick reply. So let's wait for the pulll request to be merged. Meanwhile I'll take your implementation ...

acrollet commented 5 years ago

PR has been merged, and I've updated and tried the following:

{"tsfield":"2018-08-26T12:00:00.000Z"} {"tsfield":{"type":"timestamp", "data":"2018-08-26T12:00:00.000Z"}}

The first is imported as a string, the second as an object. Anyone have a tip?

stildalf commented 5 years ago

For JSON you'll need to enclose your value in double quotes, and escape where needed, so: {"tsfield":{"type":"timestamp", "data":"2018-08-26T12:00:00.000Z"}} to: {"tsfield":"{\"type\":\"timestamp\", \"data\":\"2018-08-26T12:00:00.000Z\"}"}

Looking at that also gives me the creeps, I'll see what can be done there.

acrollet commented 5 years ago

confirm this works, thanks!

Ivanmocadaes commented 5 years ago

Hi there,

New on this, I'm trying import .json to my firestore and after install npm (I followed instructions) I tried fire-migrate import and says "fire-migrate" or "import" are no valid commands. What I'm doing wrong? Need a hand. Thanks in advanced.

samiq commented 5 years ago

this looks like has already been fixed, can someone please close this ticket? thanks!

Mickind commented 5 years ago

Hi there,

New on this, I'm trying import .json to my firestore and after install npm (I followed instructions) I tried fire-migrate import and says "fire-migrate" or "import" are no valid commands. What I'm doing wrong? Need a hand. Thanks in advanced.

Hi everyone, I have the same problem. How did you solve it? Thank you!

basementaspirations commented 5 years ago

hello there,

So, I am using the the fire-migrate import command and assign my own doc id.

fire-migrate import --id u missing.csv Articles

now when I try to search the data for a certain ID using an IOS app, it cannot find it. When I try to add the article through my app, it refreshes this record that got uploaded and updates the doc ID. after this step, the app is able to locate the article. There seems to be some issue with how doc ID is written during the upload process.

I have a video that I can show which shows the record update process in firestore. I really cannot see what changed, but it clearly seems to update the doc ID apart from some few document fields which is understandable.