Back

How to create collection for Flutter to appwrite?

  • 0
  • Databases
  • Flutter
Nuaiman
25 Jun, 2023, 08:42

Hi, I will attach an image below from an old tutorial, which I cannot reproduce anymore.

TL;DR
To create a collection for Flutter to appwrite: - You cannot directly create a collection with the Flutter SDK - Instead, you can create a cloud function that creates the collection (passing the id as a parameter) when executed from the client side - Check the documentation on how to create a collection using server-side SDK (https://appwrite.io/docs/server/databases?sdk=dart-default#databasesCreateCollection) - If you encounter a 404 error (No such Collection) while performing CRUD operations on a collection, you can call your server-side function to create a new collection for the current user. - The image
Hassanmrwt
25 Jun, 2023, 08:44

There is no way to create collection with Flutter SDK. You should call a server side Function for creating collection with Flutter

Nuaiman
25 Jun, 2023, 08:45

so the code in the image is redandant now?

Hassanmrwt
25 Jun, 2023, 08:53

There is no such Function db.getCollection() for Flutter SDK. You can try like, performing a CRUD on a Collection and if e.code is 404 (No such Collection) then call your Server Function and create new Collection for current user

Hassanmrwt
25 Jun, 2023, 09:02

Please check these Snippets to clear your concept

Maniac_Fighter
25 Jun, 2023, 10:10

Hey, The following snippet is used to get the following collection of the given customId. This project uses both Server + client side SDK to do that. (Server Side to create collections and attributes) .

It will take a while to update the code and blogs to latest version (probably end july)

But to create the collection, you can create cloud function that create the collection for you ( you can pass the id in the params when execution from the client side) You can check at this snippet (https://appwrite.io/docs/server/databases?sdk=dart-default#databasesCreateCollection)

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