
I'm trying to update the data which has been stored on a Collection in ENUM Type. I using the user id as document id during it's creation. I have no issues while creating and deleting it, but I'm facing issues when i tried to update the values.
This is the structure of data which has been stored,
{
profile: {
links: {
github: "xxx",
linkedin: "xxxx",
},
about: "",
points: 0,
courseStats: {},
},
}
This is how i tried to update the document,
const updateUserData = async (
fieldToUpdate,
dataToUpdate,
isNested = false,
fieldToInsert
) => {
try {
// Update document
const updatedDocument = await databases.updateDocument(
"DOCUMENT-ID",
"COLLECTION-ID",
user.$id, // Acts as DOCUMENT-ID
isNested
? {
profile: {
...userData,
[fieldToUpdate]: {
...userData[fieldToUpdate],
[fieldToInsert]: dataToUpdate,
},
},
}
: {
profile: {
...userData,
[fieldToUpdate]: dataToUpdate,
},
}
);
// Update state with the new document data
setUserData(updatedDocument.profile);
} catch (error) {
console.error("Error updating document:", error);
}
};
After this function's execution, the backend only returns this error,
Error updating document: [AppwriteException: Invalid document structure: Attribute "profile" has invalid format. Value must be one of (links, about, points, courseStats)]

Uhh you can't nest data like that with an enum attribute...would you please share your collection as JSON? If you inspect the network logs in your browser while viewing the loading the collection in the Console, there should be an API call for the collection
Recommended threads
- Is my approach for deleting registered u...
A few weeks ago, I was advised not to use the registered users' id in my web app. Instead, I store the publicly viewable information such as username and email ...
- ❗[Help] Function stuck in "waiting" stat...
Hi Appwrite team 👋 I'm trying to contribute to Appwrite and followed the official setup instructions from the CONTRIBUTING.md guide to run the platform locall...
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
