How to update Firebase Timestamp via JsonSchemaForm?

Hi community!

We have Timestamp type data in our Firestore and want to update them from query.

I created a JsonSchemaForm which trigger a query with action type “Update document”. I could update string, number, boolean, etc properties but could not update properties with firebase.firestore.Timestamp type. When I update properties, the type of properties changed to string like 2020-05-03T06:22:09.417Z.

Is there any way to update timestamp properties with keeping their type ?

Thank you very much!

Hey @nakamura! To do this currently you’ll need to convert the property to a timestamp explicitly via {{ moment(timestamp_here) }}. We’re working on supporting it out of the box this week!

1 Like

Hi @justin, Thank you for quick replying!

Okay, I will try converting timestamp with moment. I have following jsonSchemaForm. Where can I convert the property (lastLogin) to a timestamp?

The submit button of this jsonSchemaForm call an update document query.

{
  "title": "Users form",
  "description": "A form for editing users",
  "type": "object",
  "required": [],
  "properties": {
    "lastLogin": {
      "type": "string",
      "title": "lastLogin"
    },
    "id": {
      "type": "string",
      "title": "id"
    },
    "createdAt": {
      "type": "string",
      "title": "createdAt"
    },
    "name": {
      "type": "string",
      "title": "name"
    }
  }
}

@nakamura in the query you’re using to send the update object to the update document query

@justin Thank you very much ! I have been able to convert the property to a timestamp at “Value” of the update document query like following screenshot.

Thank you for working on supporting it out of the box!

1 Like