FQL 10 - How to transform a time into a string?

One issue that I usually face when using the fauna driver is the serialization into JSON and I’m wondering if with FQL 10 there is a way to transform a time into a string directly in query.

Using this query as an example:

products.all(){ createdAt }

Would be a similar way to do something like that?

products.all(){ createdAt: toString(createdAt) }

I was able to get it working by doing the following:

let validJSONSales = sales.map((sale) => Object.assign(sale, { createdAt: sale.createdAt.toString() }))

But I’m wondering if there is an easier way :thinking:

Date and Time in have .toString methods in FQL.

You can alias createdAt with the transformed value. For example,

  createdAt: .createdAt.toString()
1 Like

Awesome! I will read more about this alias thing.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.