Web Developer
Hello, I am trying out the new bulk operations feature, and I am experiencing some problem:
I am trying to call database.updatedocuments, and I am passing in the data you can see in the attached screenshot, but I get this error
❌ Server-side rule application failed after 81076ms: AppwriteException: Invalid document structure: Missing required attribute "user_id"
at async POST (src/app/api/apply-rules/route.ts:384:19)
382 |
383 | // Wait for batch to complete
384 | const result = await userClient
| ^
385 | .generateServerClient()
386 | .updgradeToAdmin()
387 | .databases.upsertDocuments( {
code: 400,
type: 'document_invalid_structure',
response: '{"message":"Invalid document structure: Missing required attribute \"user_id\"","code":400,"type":"document_invalid_structure","version":"1.7.4"}'
}
but as you can see I have that field filled.
I have tried with bot updateDocuments and upsertDocuments, but the problem is the same.
Moveover, in the documentation I see that the payload to send to updateDocuments should be this:
const result = await databases.updateDocuments(
'<DATABASE_ID>',
'[COLLECTION_ID]',
{
{
documentId: 'document-id-1',
data: { name: 'Updated Document 1' }
},
{
documentId: 'document-id-2',
data: { name: 'Updated Document 2' }
}
}
);
Which I think is wrong because it is not a valid javascript object. So I made it an array with those object, but the problem is still there