I’m migrating documents into Fauna that have an array if id’s [{id:1},{id:2},{id:3}].
These id’s corresponds to references from another collection, so I’m trying to set up a new array with Refs to do things the Fauna way.
I’m still very new, so confused over when to use a nested Map or if I should rather use Append.
This code throws a “Bad request” error.
let update = await client.query(
q.Let(
{
ref:q.Ref(q.Collection('users'), id),
user:q.Get(q.Var('ref')),
array:q.Select(['data','recos_received'],q.Var('user')),
},
q.Update(q.Var('ref'),{
data: {
recos_receivedRefs:
q.Map( q.Var('array'),
q.Lambda('item', q.Ref(q.Collection('recos'), q.Var(['item', 'id']) ), ),
)
,
}
})
),
)
Thanks in advance for any pointers.