that is what i am asking why should we use either one of them , and what if i use main instead of start
You must use start. Your code is injected into our server code which runs using main and you can only have one main function. See https://github.com/open-runtimes/open-runtimes/blob/801c6a833aec4ec72fc8562b5dffba2b3967ed6b/runtimes/dart-2.17/server.dart#L37
visited the link but did not find what is the actual use of start
await user_code.start(request, response);
In this code, user_code is the code that you write in your cloud function. So when your code is passed into appwrite's server, it looks for the start function in your code, and not main.
Another reason as Steven stated, is that there cannot be 2 main functions in one program. main is where the execution begins, and there can't be two starting points.
If you look through the code in the link he sent, you'll see that line 11 has a void main().
Hope that makes sense.
got your point, but there is still one doubt, is start is used for getting response and for making request and accessing environment variable?
right ?
yes that's correct!
you don't need to worry about the underlying code that runs your cloud function. If you have dependencies and environment variables, you can use them in your function, in the start().
For a detailed explanation on dependencies and more in regards to cloud functions, head to this link, and click on the Dart tab to see it's documentation.
Thanks man
No problem <:appwritecheers:892495536823861258>
as you suggest i have to use start, but in this link why not used start, any suggestion you would like to give and also which package should i use (dart_appwrite or appwrite)https://github.com/lohanidamodar/30daysofappwrite_email_sendgrid/blob/main/main.dart
I think the reason that this particular code uses main(), is because that's how the cloud functions were setup at the time.
If you notice, the code you sent was updated 2 years ago, which was way before Appwrite v1.x
yes i am aware of that
As a matter of fact, I looked at the code examples from 2 years ago, and cloud functions seem to have used main() instead of start()
To answer your question about which package to use:
If you're using appwrite in a Flutter application, use appwrite: https://pub.dev/packages/appwrite
If you're using appwrite in a Dart-only application, use dart_appwrite: https://pub.dev/packages/dart_appwrite
Since you're using the server sdk, which supports only Dart, use dart_appwrite
okay,
what are function variable and how to use them and also trigger
please make a new post for a different question. helps keep different questions in their own discussion
and let me know if you need any more help with the question for this post. if not, I'll mark it as solved 🙂
ok you can marked as solved
[SOLVED] Difference between main() and start() in Dart Server SDK
Recommended threads
- Function deployment failed: Unable to re...
Hi Appwrite team, I have been experiencing persistent errors when i attempt to push my appwrite functions. The logs on the deployment detail page on the console...
- My cloud functions failing 3 days ago (P...
Hi, My cloud function using python has been failing for 3 days, I didn't push any new deployments... Its something to do with it not recognising the entrypoi...
- Scheduled works locking the entire Maria...
I have a scheduled function and apparently that or something is locking the entire MariaDB database and Appwrite is giving MariaDB errors. This error persists e...