Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Date saved to Firestore get retrieved as strings #604

Closed
shawndewet opened this issue Jan 12, 2018 · 3 comments
Closed

Date saved to Firestore get retrieved as strings #604

shawndewet opened this issue Jan 12, 2018 · 3 comments
Assignees
Milestone

Comments

@shawndewet
Copy link

shawndewet commented Jan 12, 2018

I opened this stackoverflow question, during the course of which I thought/realized the problem might be in this nativescript-plugin?

This is the code that retrieves the data:
return query.get() .then(querySnapshot => { querySnapshot.forEach(rec => { let availabilityRec = rec.data(); console.log("existing availabilityRec() => " + JSON.stringify(availabilityRec));

A breakpoint in Chrome DevTools on that console.log() line reveals availabilityRec.theDate property to be a string.
What should I be doing to have this query return theDate property as a Date object?

@EddyVerbruggen
Copy link
Owner

EddyVerbruggen commented Jan 15, 2018

Is this on Android, iOS or both?

While working on the plugin I noticed something similar on Android (didn't check iOS yet). The reason is the plugin is using Google's Gson library to serialize Java to JSON and the result is a String.

I could fix that with a Gson Type Adapter, but I may have to resort to manual conversion anyway because the Firestore reference type isn't compatible with Gson.

@EddyVerbruggen EddyVerbruggen added this to the 5.1.3 milestone Jan 15, 2018
@EddyVerbruggen EddyVerbruggen self-assigned this Jan 15, 2018
@shawndewet
Copy link
Author

Yeah it's on the Android emulator (I don't have a Mac environment so have not taken the time to test if it's a problem there as well).

@EddyVerbruggen
Copy link
Owner

EddyVerbruggen commented Jan 15, 2018

Just checked iOS: it's fine. With 5.1.3 Android will be fine as well.

For anyone reading this: it only concerned Dates on Android, not all data.

EddyVerbruggen added a commit that referenced this issue Jan 15, 2018
#577 Firestore References can't be parsed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants