capacitor-firebase icon indicating copy to clipboard operation
capacitor-firebase copied to clipboard

feat(firestore): support all `FieldValue`

Open ocavue opened this issue 2 years ago • 5 comments
trafficstars

Plugin(s)

  • [ ] Analytics
  • [ ] App
  • [ ] App Check
  • [ ] Authentication
  • [ ] Crashlytics
  • [X] Cloud Firestore
  • [ ] Cloud Messaging
  • [ ] Performance
  • [ ] Remote Config

Current problem

The current @capacitor-firebase/[email protected] doesn't support FieldValue.serverTimestamp, FieldValue.arrayUnion etc yet.

Preferred solution

Add support for all FieldValue

Alternative options

No response

Additional context

No response

ocavue avatar Sep 28 '23 14:09 ocavue

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.

robingenz avatar Sep 29 '23 07:09 robingenz

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

orestis-z avatar Jan 07 '24 00:01 orestis-z

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!

Cosmicist avatar Apr 17 '24 01:04 Cosmicist

@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.

robingenz avatar Apr 17 '24 07:04 robingenz

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.

Cosmicist avatar Apr 17 '24 13:04 Cosmicist