Back

General error

  • 0
  • Self Hosted
  • Web
Hugo ;)
20 Mar, 2024, 21:34

Hey, i'm using this code to create a database, then create a collection in it, but it return this :

Here's the code

TypeScript
const Creation_DB = databases.create(databaseId, databaseName);
    const Info_Creation = databases.createCollection(databaseId, `${databaseId}_INFO`, 'Informations');
    await Creation_DB;
    await Info_Creation;

And here's the error that docker compose logs give me [Error] Timestamp: 2024-03-20T21:32:06+00:00 appwrite | [Error] Method: POST appwrite | [Error] URL: /v1/databases/:databaseId/collections appwrite | [Error] Type: Utopia\Database\Exception\Structure appwrite | [Error] Message: Invalid document structure: Missing collection attribute $collection appwrite | [Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php appwrite | [Error] Line: 3070

TL;DR
Developers are having issues with creating a database and then creating a collection inside it. The error message indicates that the collection attribute "$collection" is missing. Adding a delay before creating the collection may help as the database creation might not have completed.
Hugo ;)
20 Mar, 2024, 21:35

That, or sometimes it throws me a 404 database not found while it does exist

Hugo ;)
20 Mar, 2024, 21:42

Adding await delay(5000); seems to help, maybe the database hasnt been created at the time where im trying to do the request ?

Hugo ;)
20 Mar, 2024, 21:42

(that's weird thought, i'm using async / awaits)

D5
20 Mar, 2024, 22:06

What's your appwrite version and your SDK version?

Hugo ;)
20 Mar, 2024, 22:06

1.5.3

Hugo ;)
20 Mar, 2024, 22:06
D5
20 Mar, 2024, 22:07

Yes, could be πŸ€”

D5
20 Mar, 2024, 22:09

From what I understand, you're basically in info_creation, creating a collection inside the database created in creation_db?

Hugo ;)
20 Mar, 2024, 22:09

yea

Hugo ;)
20 Mar, 2024, 22:10

im basically trying to create a collection inside the database i just made

D5
20 Mar, 2024, 22:10

Where does database id come from?

Hugo ;)
20 Mar, 2024, 22:35

an arg

Hugo ;)
20 Mar, 2024, 22:35

basically it's something along thoses lines

Hugo ;)
20 Mar, 2024, 22:35
TypeScript
db_username_projectname_accountid
ideclon
21 Mar, 2024, 00:27

The function returns when the create database request has been added to the queue, but that doesn't necessarily mean it's actually been created yet

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