[SOLVED] the cloud document creation doesn't register my relationships inside it
- 0
- Databases
- Web
- Cloud
Yeah i just found out the problem is with the relationships if they have the same items in them it will not create another order it will replace the order that has been created, can u suggest me anyways to fix this?
What are the relationship attributes and what are the relationship types?
The orders have a relation of one to many to items and one to one to address, and the itemBlocker has a one to one relation to order and item
Should i send a picture of the collection attributes?
it will replace the order that has been created
Also, what do you mean by this?
orders have a relation of one to many to items
two way?
One way
Well I’m the first time seeing this but when i createDocument in orderResult for the second run it will throw that error. Document with that ID already exists. Like it’s creating a document
do you have any unique indexes?
No I don’t.
I just tried to do something like:
const orderResult = await database.createDocument("654b2f6a8af9b2ed391f", "6564217c78122dc22f6f", ID.unique(), orderRequest);
and it worked fine...
What API call exactly is failing?
Does it have a relation in it?
try {
const result = await Appwrite.functions.createExecution(
"6566e3017ed5ff75b429",
JSON.stringify(order),
false,
"/",
"POST"
);
console.log("Executed");
console.log(result);
} catch (e) {
console.log(e);
throw e;
}
}
i'm calling this function
id?: string | null;
userId: string;
items: RequestSelectedItems[];
}
interface RequestSelectedItems{
itemId: string;
quantity: number;
}```
this is the model of order i'm sending
example like this i just created an order with two items inside it, then created another order with the same two item inside it it just stole the items inside it from the previoues order.
ohhhhh actually, i was able to reproduce...
soo i think it's because it's a one to many relationship. Regardless of it being only 1 way, an item can only be linked to 1 order. You may need to use a many to many relationship
Yesss thank you so much, it fixed it . But is this a problem with appwrite or just how sql works?
I think it's behaving as designed
Thank you so much
[SOLVED] the cloud document creation doesn't register my relationships inside it
internal server when i am trying to create a new document async addProduct(prodData) { try { return await this.databases.createDocument( conf.appwriteDatabaseId, conf.appwriteCollectionId, ID.unique(), prodData ); } catch (error) { console.log("databaeService::addproduct::error: " + error); } }
check permissions for related collections
Recommended threads
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Need Help with Google OAuth2 in Expo usi...
I'm learning React Native with Expo and trying to set up Google OAuth2 with Appwrite. I couldn't find any good docs or tutorials for this and my own attempt did...