Rank 1: Thread
I am building an e-commerce application using Angular, I am trying create relationship between userProfiles and Orders collection. I have created the relationship in the Appwrite console.
My problem is, when i include the userId, into the Orders collection, its throwing error saying Invalid document structure.
async createOrder() {
try {
let datas = this.cartItems;
let userId = this.storageService.getUserId();
let data:any = [];
datas.forEach ((el:any) => {
data.push(JSON.stringify(el))
} )
await this.databases.createDocument(
environment.databaseId,
'Orders',
ID.unique(),
{
OrderItems: data,
userProfiles: userId
}
);
console.log('Order was created successfully');
} catch(e) { console.log(e);}
}