
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);} }

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

what typeo f attribute is userProfiles?

its relationship

sorry i was asking for more details about it


what should i use for attribute key? i am using the default value shown during the attribute creation

whatever you want

await this.databases.createDocument( environment.databaseId, 'Orders', ID.unique(), { OrderItems: data, userProfiles: userId } );

am i doing correct?

again, it's best to wrap multi line code with 3 backticks

can you share the details of the orders attribute?


the attribute not the collection

and can you share the exact error message please?


AppwriteException: Invalid document structure: Unknown attribute: "__zone_symbol__state" at Client.<anonymous> (http://localhost:8100/default-node_modules_appwrite_dist_esm_sdk_js.js:914:17) at Generator.next (<anonymous>) at fulfilled (http://localhost:8100/default-node_modules_appwrite_dist_esm_sdk_js.js:548:24) at _ZoneDelegate.invoke (http://localhost:8100/polyfills.js:8189:158) at Object.onInvoke (http://localhost:8100/vendor.js:55707:25) at _ZoneDelegate.invoke (http://localhost:8100/polyfills.js:8189:46) at Zone.run (http://localhost:8100/polyfills.js:7972:35) at http://localhost:8100/polyfills.js:9050:28 at _ZoneDelegate.invokeTask (http://localhost:8100/polyfills.js:8216:171) at http://localhost:8100/vendor.js:55394:49

that's weird...it says your passing __zone_symbol__state

is this being executed client side?

yes

on browser

can you open the browser dev tools, switch to the network logs, look for the POST request for this create document API call, and share the request body?

sorry, i have added await / async the zone_symbol_error gone away

its working now

[SOLVED] looking some help in relationship
Recommended threads
- my database attribute stuck in processin...
when i created attributes in collection 3 of those attributes become "processing", and they are not updating, the worst thing is that i cant even delete them s...
- Forever Processing Issue
I encountered an issue when creating attributes in the collections . if you create an attribute of type string for example and choose a size of 200 or 250 or a...
- Realtime Disconnects and Error: INVALID_...
Hi! I just want to ask here if there's any workaround with the disconnect issues we're encountering when subscribing to realtime events in react native using ex...
