Hey fellow appwriters! I am trying to make a script to initialize my Flutter/Appwrite project and I have a few questions (I am quite junior in development so pardon me if some are obviously wrong or impossible):
- Is it possible to write a JSON file (a bit like appwrite.json) containing raw informations like database id/name, collection attributes, teams, etc., but also some initial data, like an admin user, documents, memberships, etc. and execute it to create some kind of project starter? Or do I have to manually create a project and insert my initial data in Appwrite's console?
- If the first assumption is impossible, is it possible to write a sequence of commands that can automatize every step from project creation to initial data insertion without needing to use Appwrite's console or write Dart code? (nothing's wrong with Appwrite's console of course, I'm just trying to automatize my project initialization! 😅 )
- So now you have understood where I'm going, so if both first methods are impossible, do you have any tips on how I could do what I intend?
Thanks in advance,
LaurentLP
Since you already know about appwrite.json, you're already aware of appwrite cli. The appwrite cli should be able to help you with your first approach. Unfortunately, I don't have any examples though but appwrite <command> --help should get you far.
Thanks for your response! Indeed I know about appwrite CLI and I will dive more into it. At first glance it seems to be satisfying
@Ernest Thanks to you (through this topic and others) I have been able to write my full script, so thank you again!
As feedback from this experience, I can say that the help and error messages are not so clear about the syntaxe in the command. Scopes of API keys, JSON values (like user or team prefs) and permissions for collections should maybe be explained a bit more. Also it seems that the CLI shows an error when adding a required collection attribute because the default value is not set : "✗ Error Cannot convert undefined or null to object", but it is not possible to set a default value to a required attribute. It's not critical because attributes can be created even if the error message appears but it raises doubt.
Great, you got it working. I suggest you create issues for some of the bugs you noticed on the appwrite sdk-for-cli repo. Also, you can contribute examples to the docs. As Steven pointed out, there are some examples in the README of the repo just not on the website.
Please rename this post title as solved
[SOLVED] Making a script to initialize project
Recommended threads
- CORS error only on tables db api After u...
I've recently updated my self hosted appwrite instance to the 1.8.0 and updated my frontend with the tables db apis but strangely, even if I'm able to log in, g...
- [SOLVED] Access ExecutionStatus of a fun...
I am calling a cloud function from the newest Flutter SDK 20.2.1with the `xasync: false` flag and get the result, but the `execution.status` is not a String and...
- Appwrite isn't accepting the api from se...
Error creating user: AppwriteException: Server Error type: 'general_unknown', response: '{"message":"Server Error","code":500,"type":"general_unknown","versi...