firestore-backup-restore
firestore-backup-restore copied to clipboard
Timestamp field fails to import nanoseconds
Hello!
I'm trying to import a date field with nanoseconds, the problem is, when I query the data from Firestore I always get 0 nanoseconds.
I'm using v1.1.0. My client is in Angular Fire v7.3.0.
This is my json data:
{
"mycollection": [
{
"date": {
"_seconds": 1598507986,
"_nanoseconds": 660000000
}
}
]
}
The response:
date: at {seconds: 1598507986, nanoseconds: 0}
I tried using dates: ['date'] and autoParseDates: true. Both ways the dates are parsed ok, and they're displayed correctly in Firebase Console, but since it won't show nanoseconds, I can't tell if they are being imported ok.
Am I doing something wrong, or does it have to do with the client?
Ok, is not the client. I manually added the document and the client responded with the correct nanoseconds value.
@drmencos how did you try with the client?
@dalenguyen, thanks for your answer. I converted the date object to a Timestamp before sending the document:
myDocument.date = new Timestamp(myDocument.date._seconds, myDocument.date._nanoseconds);
addDoc(collection(db, 'mycollection'), myDocument);