Rank 1: Thread
Hi, i have some problems during updating of a document in a Two-way relationship table.
I'm on:
-Appwrite Cloud
-Web SDK 10.2.0
DB structure:
food : { name : string (required), ingredients : relations to "food_ingredients" (manyToMany)}
food_ingredients : { quantity : integer (required), ingredients : One-way relation to "ingredients" (manyToMany), food: relations to "food" (manyToMany)}It's simple,
step to replicate:
- create food doc:
food = this.db.createDocument(this.base_db, 'food', Appwrite.ID.unique(), {name : 'food_1'})- create food_ingredients with food relation doc:
this.db.createDocument(this.base_db, 'food_ingredients', Appwrite.ID.unique(), food_ingredients = {quantity : 1, ingredients : [ingredient.?id], food : [food.$id]})now,
Now if I take the food document, I also receive the associated food_ingredients list
- but,
when i try to edit food doc, i receive an exception:
this.db.updateDocument(this.base_db, 'food', food.$id, {name : 'food_1_updated'})I've tried:
this.db.updateDocument(this.base_db, 'food', food.$id, {name : 'food_1_updated', ingredients : null})
this.db.updateDocument(this.base_db, 'food', food.$id, {name : 'food_1_updated'},ingredients : [])
this.db.updateDocument(this.base_db, 'food', food.$id, {name : 'food_1_updated'},ingredients : [food_ingredients.$id])but i alway receive:
{ "name":"AppwriteException", "code":400, "type":"document_invalid_structure", "response":{ "message":"Invalid document structure: Unknown attribute: 'food_ingredients'", "code":400, "type":"document_invalid_structure", "version":"0.13.23" } }thanks everyone in advance
P.S:
funtions.client = new Appwrite.Client().setEndpoint().setProject()
this.db = new Appwrite.Databases(functions.client),