forked from pooranjoyb/cpp-sdk-appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateDocument.cpp
More file actions
33 lines (28 loc) · 1004 Bytes
/
createDocument.cpp
File metadata and controls
33 lines (28 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Appwrite.hpp"
#include <iostream>
#include <string>
int main() {
std::string projectId = "66fbb5a100070a3a1d19";
std::string apiKey = "";
std::string databaseId = "database123";
std::string collectionId = "test1234";
std::string documentId = "document1231";
std::string rawData = R"({
"new_email_attribute": "pou@email.com",
"new_enum_attribute": ["element1234"],
"UpdatedFloat123": 9.0,
"UpdatedInteger123": 123,
"UpdatedIPaddress123": "192.168.1.1",
"UpdatedString123": ["abc", "def"]
})";
Appwrite appwrite(projectId, apiKey);
try {
std::string response = appwrite.getDatabases().createDocument(
databaseId, collectionId, documentId, rawData);
std::cout << "Document created successfully!\nResponse: " << response
<< std::endl;
} catch (const AppwriteException &ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}