Firestore: ServerValue.TIMESTAMP occasionally resulting in { ".sv": "timestamp" }

1,526 views
Skip to first unread message

Manish Malik

unread,
Nov 17, 2017, 1:15:40 AM11/17/17
to Firebase Google Group
Hi,

I have a simple update on a property whenever the user performs a particular action:

(JS code)

        let dbUserRef = firebase.firestore().collection("dummyactionrecords").doc(UID);
        dbUserRef.update({
            lastUpdated: firebase.database.ServerValue.TIMESTAMP
        })

Occasionally, instead of updating the field "lastUpdated" with a timestamp, it gets the value { ".sv": "timestamp" }. I say "occasionally", because I haven't been able to detect a pattern on why some of the objects get a proper timestamp, while others don't. I had seen this mentioned on threads using RTDB in the past, but I haven't found a relevant one on Firestore.

While I try to figure out a pattern and then a reason, any pointers / idea would be great.

Thanks.

Michael Bleigh

unread,
Nov 20, 2017, 12:40:01 AM11/20/17
to fireba...@googlegroups.com

You are using the rtdb server value. You need:

firebase.firestore.FieldValue.serverTimestamp()


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/32b8a74f-035e-49b6-9112-74b5ae8b38b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manish Malik

unread,
Nov 21, 2017, 10:16:40 AM11/21/17
to Firebase Google Group
Thanks for the catch! Turned out to be the residue from rtdb -> firestore code conversion. Fixed!
Reply all
Reply to author
Forward
0 new messages