Reputation:
I'm writing a new document to Firestore. One of the fields must have some text, followed by the date, formatted like so 10/11/2020, 13:07
. What would be the simplest way to achieve this? I have an exceptionally convoluted way of achieving this with Moment.js in an old project. But I would like to see if there's a more elegant approach.
this.doc.set({
title: "A New Title " + ,
date: firebase.firestore.FieldValue.serverTimestamp(),
})
In the above snippet, the title would need to be something like title: "My New Title " + date"
so that the final result is something like: My New Title - 10/11/2020, 13:07
Upvotes: 0
Views: 90
Reputation: 600090
There is no way to merge a server-side timestamp with another value in a single write.
You will either have to:
Upvotes: 0