visited doc but not get any idea,
Basically you create one to make a specific thing with your data or backend and then you trigger it to be executed from an app, an event (database, Auth), manually or scheduled
any basic idea if you can provide like what is happening in this function or what is use for res and req and how to trigger on event or create document from function ```Future<void> start(final req, final res) async { final client = Client();
//Uncomment the services you need, delete the ones you don't final account = Account(client); final avatars = Avatars(client); final database = Databases(client); final functions = Functions(client); final health = Health(client); final locale = Locale(client); final storage = Storage(client); final teams = Teams(client); final users = Users(client);
if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { print( "Environment variables are not set. Function cannot use Appwrite SDK."); } else { client .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) .setSelfSigned(status: true); }
res.json({ 'areDevelopersAwesome': true, }); }```
What it makes is showing a response who is 'areDevelopersAwesome': true
What's inside the Future<void> function is what's executed
Other things are requests made to start appwrite services. You can delete what you will not use
do you have any idea for creating document from function so that i can create 10 document in just single click ?
Same as you would have done with flutter: run this 10 times for each document you need to create:
import 'package:appwrite/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
;
Future result = databases.createDocument(
databaseId: '[DATABASE_ID]',
collectionId: '[COLLECTION_ID]',
documentId: '[DOCUMENT_ID]',
data: {},
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
If I'm not wrong, currently it's not possible to bulk-create documents, so you will need to trigger the above code the same amount of times as documents you will need. However such feature has been suggested: https://github.com/appwrite/appwrite/issues/3051
You can give it a 👍
Recommended threads
- Repository directory size should be less...
Whenever I create a function i get the error above. Is there a way to get around this? How do I fix this?
- "Waiting" executions
For my React Native App, I have had no issues deploying a function in Appwrite & the executions either working or failing. Now I am getting status code - 0 & j...
- Deployed to live, but functions only wor...
Deployed my serveless functions, noticed a request is only sent when I switch on my vpn, I have a feeling it's an ip related thing, I'd like some help troublesh...