Search code examples
faunadb

How to convert q.Now() results to String in fauna


I have createdAt key that I get from

Create(Collection("clients"), {
  data: {
    createdAt: Now()
  }
}

But the JSON returns

"createdAt": {
    "@ts": "2020-11-02T10:09:55.316781Z"
  },

How to returns only

"createdAt": "2020-11-02T10:09:55.316781Z"

Thank you


Solution

  • Don't know why, but after I tried many scenarios, turns out you can get the value with createdAt.value

    UPDATE: you can convert to string with ToString() method before uploading to fauna. e.g. ToString(Now())

    it'll return 2020-11-02T13:18:23.383908Z

    Thank you.