Rank 2: Process
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?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 2: Process
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?
Rank 2: Process
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
Rank 2: Process
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?
Rank 2: Process
One way
Rank 2: Process
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?
Rank 2: Process
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?
Rank 2: Process
Does it have a relation in it?
Rank 2: Process
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; } }Rank 2: Process
i'm calling this function
Rank 2: Process
id?: string | null; userId: string; items: RequestSelectedItems[];}
interface RequestSelectedItems{ itemId: string; quantity: number;}```Rank 2: Process
this is the model of order i'm sending
Rank 2: Process
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
Rank 2: Process
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
Rank 2: Process
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);
}
}
Rank 1: Thread
check permissions for related collections