Wrong type detected / Can't access Array methods

I can’t see anything wrong with the query below, but it seems that Fauna wrongly casts a type.

  let doc = dbg({
    UserStats.create({
      private: [],
      group: [],
    })
  })

  let key = 'private'
  let list = doc[key]
  list.append(Time.epoch(1591482682, 'seconds'))

  list
invalid_query

error: Type `Number` does not have field `append`
at *query*:10:8
   |
10 |   list.append(dbg(Time.epoch(1591482682, 'seconds')))
   |        ^^^^^^
   |

I know I could set the Time doc directly in the create statement, but beware that this snippet is just a simplified version of the problem.

What I am actually trying to achieve is:

  1. Upsert a UserStats doc.
  2. Add a new “hit” to the doc, but in a field dynamically defined.

I’m having trouble replicating the issue.

If there is more going on in your query, can you please provide the additional steps to replicate? Is this being used in a Function? I can see that the error does not exactly match the code sample you provided.

Hi @zvictor Are you still having issues? Please let us know if so, or if we can close this topic. Thanks!