-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcreateIndex.cpp
More file actions
28 lines (22 loc) · 836 Bytes
/
createIndex.cpp
File metadata and controls
28 lines (22 loc) · 836 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
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "66fbb5a100070a3a1d19";
std::string apiKey = "";
Appwrite appwrite(projectId, apiKey);
std::string databaseId = "database123";
std::string collectionId = "test1234";
std::string key = "index_from_cpp";
// we need to use type as "key" for arrayed attributes
std::string type = "key";
std::vector<std::string> attributes = {"new_enum_attribute"};
try {
std::string response = appwrite.getDatabases().createIndexes(
databaseId, collectionId,key, type, attributes
);
std::cout << "Index created successfully! \nResponse: " << response << std::endl;
} catch (const AppwriteException& ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}