-
Notifications
You must be signed in to change notification settings - Fork 1
/
createIndex.cpp
31 lines (24 loc) · 908 Bytes
/
createIndex.cpp
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
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "66fbb5a100070a3a1d19";
std::string apiKey = "";
Appwrite appwrite(projectId);
Databases& database = appwrite.getDatabases();
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"};
database.setup(apiKey, projectId);
try {
std::string response = database.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;
}