Rank 1: Thread
I have two objects, a company object and a user object. I create a company first then I create a user for the company. The structure for the company is as follows
{ name: "", ...... users: [Object object] //Relationship with user object }
The user object is:
"id": userObject.$id, "role": role, "department": department, "title": title, "about": about }```
Now, I update the company with the following piece of code:let payload = {
"id": company.$id,
"name": company.name,
"location": company.location,
"website": company.website,
"users": [{
"id": userObject.$id,
"role": role,
"department": department,
"title": title,
"about": about
}]
}
const updatedCompany = await database.updateDocument(
process.env.REACT_APP_APPWRITE_DATABASE_ID,
process.env.REACT_APP_APPWRITE_COMPANIES_COLLECTION_ID,
company.$id,
payload
)```
Problem is when I run this code, I get the following error message: Message: Invalid document structure: Missing required attribute "role"
What could I be doing wrong?