|
1 | 1 | # Appwrite C++ SDK |
2 | 2 |
|
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
3 | 8 |  |
4 | 9 |
|
5 | 10 | ## Overview |
6 | 11 |
|
7 | | -This C++ SDK is built from scratch as a prototype for interacting with Appwrite's backend services. It allows users to perform a limited set of functionalities, including the creation of databases, collections, and documents, while also enabling the retrieval of usage statistics and management of storage and account health. |
| 12 | +This **C++ SDK** is built from scratch as a **prototype** for interacting with Appwrite's backend services. |
| 13 | +- It allows users to perform a limited set of functionalities as of now, |
| 14 | +- including the **creation of databases, collections, and documents**, |
| 15 | +- while also enabling the **retrieval of usage statistics** and |
| 16 | +- management of **storage** and **account health**. |
8 | 17 |
|
9 | | -## Features |
| 18 | +**This SDK is compatible with Appwrite server version 1.6.x.** |
10 | 19 |
|
11 | | -The SDK offers essential features for database management, including the ability to create databases with authentication checks. Users can create collections within these databases and define various attributes for each collection. Additionally, the SDK supports the creation of document indexes, which facilitate efficient querying. Users can retrieve usage statistics for both databases and collections, enabling them to monitor performance and resource utilization. Moreover, the SDK includes functionalities for managing storage classes and checking the health status of the application, along with basic account management capabilities. |
| 20 | + |
12 | 21 |
|
13 | | -For a more detailed view of the implementation, please check out the example directory. [Example](/examples/) |
14 | 22 |
|
15 | | -## License |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +### Make Your First Request |
| 26 | + |
| 27 | +Set the neccessary header files. |
| 28 | +```cpp |
| 29 | +#include "Appwrite.hpp" |
| 30 | +``` |
| 31 | +Once your SDK header is set, create the Appwrite service objects and choose the request to send. |
| 32 | +```cpp |
| 33 | + std::string projectId = "<your-project-id>"; |
| 34 | + std::string apiKey = "<your-api-key>"; |
| 35 | + |
| 36 | + Appwrite appwrite(projectId); |
| 37 | + |
| 38 | + // for the Databases instance |
| 39 | + Databases& databases = appwrite.getDatabases(); |
| 40 | + databases.setup(apiKey, projectId); |
| 41 | +``` |
| 42 | +
|
| 43 | +### Full Example |
| 44 | +```cpp |
| 45 | +#include "Appwrite.hpp" |
| 46 | +#include <iostream> |
| 47 | +
|
| 48 | +int main() { |
| 49 | + std::string projectId = "<your-project-id>"; |
| 50 | + std::string apiKey = "<your-api-key>"; |
| 51 | + std::string databaseId = "<unique-database-id>"; |
| 52 | + std::string name = "<unique-database-name>"; |
| 53 | + bool enabled = true; |
| 54 | +
|
| 55 | + Appwrite appwrite(projectId); |
| 56 | + Databases& databases = appwrite.getDatabases(); |
| 57 | + |
| 58 | + databases.setup(apiKey, projectId); |
| 59 | + std::string response = databases.create(databaseId, name, enabled); |
16 | 60 |
|
17 | | -This project is licensed under the MIT License, and further details can be found in the LICENSE file. |
18 | | -[MIT LICENSE](LICENSE) |
| 61 | + return 0; |
| 62 | +} |
| 63 | +
|
| 64 | +``` |
| 65 | +### Error Handling |
| 66 | + |
| 67 | +The Appwrite C++ SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. |
| 68 | + |
| 69 | +```cpp |
| 70 | + try { |
| 71 | + // Send some request here |
| 72 | + } catch (const AppwriteException& ex) { |
| 73 | + std::cerr << "Exception: " << ex.what() << std::endl; |
| 74 | + } |
| 75 | +``` |
| 76 | +
|
| 77 | +For a more detailed view of the implementations, please check out the example directory. [Example](/examples/) |
| 78 | +
|
| 79 | +### Learn more |
| 80 | +You can use the following resources to learn more and get help |
| 81 | +- 🚀 [Getting Started Tutorial](youtube-link) |
| 82 | +- 📜 [C++ SDK Docs](/docs) |
| 83 | +
|
| 84 | +
|
| 85 | +## License |
| 86 | +This project is licensed under the MIT License, and further details can be found in the [LICENSE](LICENSE) file. |
0 commit comments