capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
410 stars 105 forks source link

feat(firestore): support all `FieldValue` #443

Open ocavue opened 1 year ago

ocavue commented 1 year ago

Plugin(s)

Current problem

The current @capacitor-firebase/firestore@5.1.0-dev.b89276d.1695905786 doesn't support FieldValue.serverTimestamp, FieldValue.arrayUnion etc yet.

Preferred solution

Add support for all FieldValue

Alternative options

No response

Additional context

No response

robingenz commented 1 year ago

Thank you, this is indeed missing. I will have to check how we can implement this feature, since with Capacitor you can only pass plain JSON over the bridge.

orestis-z commented 11 months ago

Here a working example for Android + FieldValue.increment: https://github.com/capawesome-team/capacitor-firebase/compare/main...orestis-z:capacitor-firebase:main#diff-047d76fdd82cc667e41c3f3ec57900e9dd1448ab35a5714c8bcd9bc8282e7427

Cosmicist commented 7 months ago

Is there any update on this issue? I saw a now closed PR with a solution that looks promising https://github.com/capawesome-team/capacitor-firebase/pull/475 and wonder if something like this will be implemented at some point since it is an important missing feature.

In the meantime, is there some kind of js-side workaround that we could be using? (I mean while still using the native sdk) . Sorry if this is an obvious question, but I couldn't find a way yet.

Thanks!

robingenz commented 7 months ago

@Cosmicist No, there are currently no updates. I will use the approach from #475 to fix this issue. Unfortunately, I can't give an ETA yet because this issue is quite complex.

In the meantime, is there some kind of js-side workaround that we could be using?

No, unfortunately not. There are workarounds for some field values. For example, you could replace FieldValue.serverTimestamp with a Firebase Cloud Function that updates the document as soon as it's created or updated.

Cosmicist commented 7 months ago

Hey @robingenz! Thanks for the input, I really appreciate it.

I like the cloud function idea, I'll probably try it for writes. For querying though I'll probably need to resort to the web sdk for the time being.