Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Missing create function for databases. #209

Open
2 tasks done
Vildnex opened this issue Jun 28, 2024 · 2 comments
Open
2 tasks done

🐛 Bug Report: Missing create function for databases. #209

Vildnex opened this issue Jun 28, 2024 · 2 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Vildnex
Copy link

Vildnex commented Jun 28, 2024

👟 Reproduction steps

Trying to call the following code from this documentation:

import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
  Client client = Client();
  Databases databases = Databases(client);

  client
    .setEndpoint('https://<MY_LOCAL_IP>/v1') // Your API Endpoint
    .setProject('<ID_PROJECT>) // Your project ID
    .setKey('<SECRET_KEY>) // Your secret API key
  ;

  Future result = databases.create(
    databaseId: '<DATABASE_ID>',
    name: '<NAME>',
  );

  result
    .then((response) {
      print(response);
    }).catchError((error) {
      print(error.response);
  });
}

👍 Expected behavior

I would expect that code to create a new database with a specific ID and NAME.

👎 Actual Behavior

But instead, I will get the following error message:

The method 'setKey' isn't defined for the type 'Client'. (Documentation) Try correcting the name to the name of an existing method, or defining a method named 'setKey'.

The method 'create' isn't defined for the type 'Databases'. (Documentation) Try correcting the name to the name of an existing method, or defining a method named 'create'.

🎲 Appwrite version

Version 2.0.x

💻 Operating system

Linux

🧱 Your Environment

I use Appwrite the the docker-compose file provided from the official documentation with the .env file from the same official documentation.

appwrite: ^12.0.4
Flutter 3.22.2
Tools • Dart 3.4.3 • DevTools 2.34.3

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@Vildnex Vildnex added the bug Something isn't working label Jun 28, 2024
@Vildnex
Copy link
Author

Vildnex commented Jun 28, 2024

I also have the same problem with the code to generate new collections:

import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
  Client client = Client();
  Databases databases = Databases(client);

  client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
    .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
  ;

  Future result = databases.createCollection(
    databaseId: '<DATABASE_ID>',
    collectionId: '[COLLECTION_ID]',
    name: '[NAME]',
  );

  result
    .then((response) {
      print(response);
    }).catchError((error) {
      print(error.response);
  });
}

error:

The method 'createCollection' isn't defined for the type 'Databases'. (Documentation) Try correcting the name to the name of an existing method, or defining a method named 'createCollection'.

@stnguyen90
Copy link
Contributor

@Vildnex, thanks for raising this issue! 🙏🏼

The Flutter SDK (appwrite) is a client SDK and doesn't expose server-side operations like creating collections. If you want to create collections, you need to use the Dart SDK (dart_appwrite), which is a server SDK, and should only be used server-side, not in an app.

@stnguyen90 stnguyen90 self-assigned this Jul 4, 2024
@stnguyen90 stnguyen90 added the question Further information is requested label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants