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
- The current user is not authorized to pe...
I want to create a document associated with user after log in with OAuth. The user were logged in, but Appwrite said user is unauthorized. User is logged in wi...
- Having issues with login via CLI
``` ~/appwrite appwrite login --endpoint https://localhost/v1 --verbose ? Enter your email myvalidemai...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...