Back

[SOLVED] Invalid document structure: Missing collection attribute $collection

  • 1
  • Web
FUZZY
31 Aug, 2023, 06:36

I have a one to one relationship between "userInfo" and "money". I tried to update money document but I am getting this error "Invalid document structure: Missing collection attribute $collection"

It looks like the collectionId in the nested userInfo is money by mistake (You can see from the screenshot).

Here is my code: const moneyData = await database.getDocument("eserica","money", id); moneyData.sycee -= computeCompanyCost(level); database.updateDocument("eserica", "money", id, moneyData)

I am on npm: appwrite@12.0.0, docker: appwrite@1.3.8.

TL;DR
The user encountered the error "Invalid document structure: Missing collection attribute $collection" when trying to update a document in the "money" collection. They realized they were passing in the wrong field to be updated. They discovered that the collectionId in the nested "userInfo" was mistakenly set as "money". They provided their code for reference. The user is using npm version 12.0.0 and docker version 1.3.8 of Appwrite.
FUZZY
31 Aug, 2023, 06:51

Invalid document structure: Missing collection attribute $collection

FUZZY
31 Aug, 2023, 07:42

Nevermind, I realized I am only supposed to pass in the field to be updated.

Drake
31 Aug, 2023, 18:57

so do you still have a problem?

FUZZY
2 Sep, 2023, 12:49

Nope, it's solved.

D5
2 Sep, 2023, 14:31

[SOLVED] Invalid document structure: Missing collection attribute $collection

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more