Back

Trouble with Updating Documents

  • 0
  • React Native
  • Cloud
  • REST API
suhasbr
18 May, 2024, 10:18

Hi everyone, I'm building an app using React Native expo and I've installed the SDK from appwrite - https://github.com/appwrite/sdk-for-react-native/tree/main

I'm updating documents on my database using the below code:

const result = await databases.updateDocument( config.databaseId, config.flashcardCollectionId, '66484908003a4449ef26', //documentId { statusLevel: 2, numberOfTimesShown: 2, } );

Seemingly simple but I'm running into error everytime I run this and the error is

[AppwriteException: Invalid relationship value. Must be either a document ID or a document, array given.]

I'm wondering why the error says 'array is given instead of document ID whereas the ID is clearly hardcoded string

Steps I've tried so far -> Verify the documentId -> Remove documentId entirely and check what happens - it gives a different error ; '[AppwriteException: Invalid documentId param: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore]' so I'm certain that the documentId is recognized when I pass it but it's somehow reading it as an array

Edit: I just realized this error is appearing for a document which has a relationship as one of the attribute types, although I'm not updating that attribute in this call. I just tested the code for another collection without relationship based attributes and it works fine

TL;DR
Developers are working on a React Native expo app using the appwrite SDK to update documents in a database. The error "[AppwriteException: Invalid relationship value. Must be either a document ID or a document, array given.]" is occurring even though the document ID is correctly hardcoded. The issue may be related to a relationship attribute in the document causing confusion. The update works fine for collections without relationship-based attributes.
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