Skip to content
Back

How to bulk update

  • 0
  • Databases
apperside
8 Jul, 2025, 08:46

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

TL;DR
Developers are encountering an error when using bulk operations to update documents due to a missing required attribute ("user_id"). The provided payload structure might not be valid as per the documentation. Ensure that the payload for `updateDocuments` is in the correct format, using an array of objects.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more