catchOriginal post
Web Developer
I am trying to add a new document to my database with an array.
When I try to create the document though, I get the error:
[AppwriteException: Invalid document structure: Attribute "info['1']" has invalid type. Value must be a valid string and no longer than 100000 chars]
While testing the recipeArray prints "["", [], " Minutes", 1, [{"amount": "5", "measurement": "g", "name": "shah"}], ["hello"]]" and is a valid array.
Here is my functions code:
JavaScript
export async function createRecipe(title, recipeArray, creatorId, thumbnail = null) {
try { console.log(recipeArray) if (thumbnail) { return await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.recipeCollectionId, ID.unique(), { title: title, creator: creatorId, info: recipeArray, thumbnail: thumbnail } ); } else { return await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.recipeCollectionId, ID.unique(), { title: title, creator: creatorId, info: recipeArray } ); }
} catch (error) { console.log(error) throw new Error(error); }}Summary
Issue: Error message indicates info['1'] must be a string under 100000 chars.
Solution: Make sure each element in the recipeArray is a valid string and below 100000 chars. Check the data being passed into the function to ensure it meets the required format.