Back

[SOLVED] How can I integrate server side function calls such as createDatabase or createCollection

  • 0
  • Self Hosted
  • Flutter
  • General
Binyamin
8 Aug, 2023, 14:03

In general this is not recommend as you'll expose an API key in your app, the best approach would be to use cloud-function for that matter.

If you do want to do so then you'll need to add the dart_appwrite packages and import it like so

TypeScript
import 'package:dart_appwrite/dart_appwrite.dart' as server_side;

Then use it like so,

TypeScript
 server_side.Client client = server_side.Client()
    .setEndpoint('http://[HOSTNAME_OR_IP]/v1')
    .setProject('5ff3379a01d25')
    .setKey('cd868c7af8bdc893b4...93b7535db89')
    .setSelfSigned(); 

  server_side.Users users = server_side.Users(client);

You need to do it that way because you two packages with same class names.

TL;DR
Solution: To integrate server side function calls such as createDatabase or createCollection in Appwrite, you need to make sure you have the necessary packages installed and imported in your code. Additionally, you can try changing the "dart-2.12" to "dart-2.17" in the .env file and restarting the container. If you are unable to find the .env file, make sure it is placed in the same folder as the docker-compose.yml file. Note that it is recommended to use cloud functions instead of exposing API keys in your app. If you still want to proceed, you can import the "dart_appwrite
AmanKeswani
9 Aug, 2023, 17:49

while trying to create a function using the appwrite cli, appwrite init function, im having an issue where it isnt showing dart runtime and online it shows a solution to enable a variable in the .env file in appwrite folder but i cant find where the folder is

AmanKeswani
9 Aug, 2023, 17:50

I have installed appwrite using docker at localhost

AmanKeswani
9 Aug, 2023, 17:51

@Binyamin

Binyamin
9 Aug, 2023, 17:51

The .env is an hidden file Where is your docker-compose.yml located?

AmanKeswani
9 Aug, 2023, 17:55

im not sure of that, I dont have much knowledge about docker

AmanKeswani
9 Aug, 2023, 17:55

this it the first time im using it for appwrite

Binyamin
9 Aug, 2023, 17:56

That file and the .env should be placed in the folder you've ran the install command inside appwrite folder

AmanKeswani
9 Aug, 2023, 18:01

found it

AmanKeswani
9 Aug, 2023, 18:01

it was inside the windows/system32/appwrite

AmanKeswani
9 Aug, 2023, 18:01

thank you

AmanKeswani
9 Aug, 2023, 18:08

I added dart-2.12 to teh _APP_FUNCTIONS_ENVS and _APP_FUNCTIONS_RUNTIMES and restarted the container and im still unable to see dart runtime

AmanKeswani
9 Aug, 2023, 18:12
AmanKeswani
9 Aug, 2023, 18:13

@Binyamin sorry for disturbing you continuously 😓

Binyamin
9 Aug, 2023, 18:14

How've your restarted the docker?

AmanKeswani
9 Aug, 2023, 18:15

docker desktop or docker container?

Binyamin
9 Aug, 2023, 18:15

restarted the container

Binyamin
9 Aug, 2023, 18:15

How've you done this

AmanKeswani
9 Aug, 2023, 18:15

docker-compose up -d using this and later restarting it from the desktop console

Binyamin
9 Aug, 2023, 18:16

Mmm Can you change the dart-2.12 to dart-2.17 And then rerun the docker compose up -d

AmanKeswani
9 Aug, 2023, 18:17

okay ill try

AmanKeswani
9 Aug, 2023, 18:20

that worked

AmanKeswani
9 Aug, 2023, 18:20

thanks a lot

Binyamin
9 Aug, 2023, 18:20

<:appwritefire:823999000330895380>

Tessa
10 Aug, 2023, 01:58

[SOLVED] How can I integrate server side function calls such as createDatabase or createCollection

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