Back

message: 'Invalid document structure: Unknown attribute: "$databaseId"'

  • 0
  • Web
ideclon
16 Apr, 2024, 14:25

I’m not quite clear on what you’re doing here?

TL;DR
Developers encountered an error due to an unknown attribute ($databaseId) in the document structure. The issue arises because attributes beginning with "$" are system attributes that cannot be set. To resolve this, developers need to remove these attributes from their newtag before passing it to databases.updateDocument(). The database ID should be the first parameter in the database.createDocument() or database.updateDocument() method to prevent errors.
ideclon
16 Apr, 2024, 14:26

The database ID is the first parameter to the database.createDocument() or database.updateDocument() method

wings of ice
16 Apr, 2024, 14:26
wings of ice
16 Apr, 2024, 14:27
wings of ice
16 Apr, 2024, 14:27

i have these that appwrite adds when getting the data

ideclon
16 Apr, 2024, 14:27

What is this?

wings of ice
16 Apr, 2024, 14:27

data that im getting from appwrite

ideclon
16 Apr, 2024, 14:28

So where’s the error?

wings of ice
16 Apr, 2024, 14:29
ideclon
16 Apr, 2024, 14:34

What’s the code that’s triggering that error?

wings of ice
16 Apr, 2024, 14:37

this one

ideclon
16 Apr, 2024, 14:41

Wait, that error is coming back when calling databases.listDocuments()? Not when creating/updating a Document?

wings of ice
16 Apr, 2024, 14:42

oh wait

wings of ice
16 Apr, 2024, 14:42

sorry th

wings of ice
16 Apr, 2024, 14:42

the first picture wasn't sent

wings of ice
16 Apr, 2024, 14:42

mb

wings of ice
16 Apr, 2024, 14:42
ideclon
16 Apr, 2024, 14:45

And what’s in newtag?

wings of ice
16 Apr, 2024, 14:46

{ monday: 'm', tuesday: 'azd', wednesday: 'w', thursday: 't', friday: 'f', saturday: 's', sunday: 's', user: '65e760c118cde1ce4ebf', '$id': '661e594110cd04682356', '$createdAt': '2024-04-16T10:56:01.071+00:00', '$updatedAt': '2024-04-16T14:37:08.599+00:00', '$permissions': [], '$databaseId': '65ce3bba5179ce91f4ae', '$collectionId': '65d5ded409a3fc3353db' }

ideclon
16 Apr, 2024, 14:50

Ah - so there’s your issue - all the Attributes beginning with $ are system Attributes which can’t be set.

wings of ice
16 Apr, 2024, 14:51

yess exactly

ideclon
16 Apr, 2024, 14:53

So you’ll need to remove them from newtag before passing it in to databases.updateDocument()

wings of ice
16 Apr, 2024, 14:54

yes i did that but thought if it was system attributes why wouldn't the update ignore it in the first plcae then

wings of ice
16 Apr, 2024, 14:54

thought i was doing something wrong

ideclon
16 Apr, 2024, 15:01

Yeah, I would expect it should, too.

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