Hey!
I'm having issues programatically updating an array field containing objects.
I have a CollectionAfterOperationHook that runs this code on a 'create' operation:
const { user, payload } = req
console.log('Starting')
await payload.update({
collection: 'users',
id: user.id,
data: {
projects: [
{
role: 'admin',
project: projectId,
},
],
},
})
console.log('resolved')
The user.projects is defined as follows:
{
name: 'projects',
type: 'array',
label: 'Projects',
fields: [
{
name: 'project',
type: 'relationship',
relationTo: 'projects',
required: true,
},
{
name: 'role',
type: 'select',
hasMany: false,
required: true,
options: [
{
label: 'Admin',
value: 'admin',
},
{
label: 'User',
value: 'user',
},
],
},
],
}
Whenever the hook is run the request is stuck forever and the resolved log is never printed.
I'm on beta 65 (but had the same issue with beta 60) and I'm using postgres.
Any ideas what is causing this or how to work around it?