The Databases service allows you to create structured collections of documents, query and filter lists of documents, and manage an advanced set of read and write access permissions.
All data returned by the Databases service are represented as structured JSON documents.
The Databases service can contain multiple databases, each database can contain multiple collections. A collection is a group of similarly structured documents. The accepted structure of documents is defined by collection attributes. The collection attributes help you ensure all your user-submitted data is validated and stored according to the collection structure.
Using Appwrite permissions architecture, you can assign read or write access to each collection or document in your project for either a specific user, team, user role, or even grant it with public access (any
). You can learn more about how Appwrite handles permissions and access control.
https://cloud.appwrite.io/v1
List Databases
Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.
Request
search Search term to filter your list results. Max length: 256 chars.
limit Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset Offset value. The default value is 0. Use this param to manage pagination. learn more about pagination
cursor ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.
cursorDirection Direction of the cursor, can be either 'before' or 'after'.
orderType Order result by ASC or DESC order.
Response
200
GET /databases
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.list()
puts response.inspect
Create Database
Create a new Database.
Request
databaseId requiredUnique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
name requiredCollection name. Max length: 128 chars.
Response
201
POST /databases
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create(name: '[NAME]')
puts response.inspect
Get Database
Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata.
Request
databaseId requiredDatabase ID.
Response
200
GET /databases/{databaseId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.get()
puts response.inspect
Update Database
Update a database by its unique ID.
Request
databaseId requiredDatabase ID.
name requiredCollection name. Max length: 128 chars.
Response
200
PUT /databases/{databaseId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.update(name: '[NAME]')
puts response.inspect
Delete Database
Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.
Request
databaseId requiredDatabase ID.
Response
204
DELETE /databases/{databaseId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.delete()
puts response.inspect
List Collections
Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.
Request
databaseId requiredDatabase ID.
search Search term to filter your list results. Max length: 256 chars.
limit Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset Offset value. The default value is 0. Use this param to manage pagination. learn more about pagination
cursor ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.
cursorDirection Direction of the cursor, can be either 'before' or 'after'.
orderType Order result by ASC or DESC order.
Response
200
GET /databases/{databaseId}/collections
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.list_collections()
puts response.inspect
Create Collection
Create a new Collection. Before using this route, you should create a new database resource using either a server integration API or directly from your database console.
Request
databaseId requiredDatabase ID.
collectionId requiredUnique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
name requiredCollection name. Max length: 128 chars.
permission requiredSpecifies the permissions model used in this collection, which accepts either 'collection' or 'document'. For 'collection' level permission, the permissions specified in read and write params are applied to all documents in the collection. For 'document' level permissions, read and write permissions are specified in each document. learn more about permissions and get a full list of available permissions.
read requiredAn array of strings with read permissions. By default no user is granted with any read permissions. learn more about permissions and get a full list of available permissions.
write requiredAn array of strings with write permissions. By default no user is granted with any write permissions. learn more about permissions and get a full list of available permissions.
Response
201
POST /databases/{databaseId}/collections
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]', permission: 'document', read: ["role:all"], write: ["role:all"])
puts response.inspect
Get Collection
Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
Response
200
GET /databases/{databaseId}/collections/{collectionId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.get_collection(collection_id: '[COLLECTION_ID]')
puts response.inspect
Update Collection
Update a collection by its unique ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
name requiredCollection name. Max length: 128 chars.
permission requiredPermissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the
read
andwrite
params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. learn more about permissions and get a full list of available permissions.read An array of strings with read permissions. By default inherits the existing read permissions. learn more about permissions and get a full list of available permissions.
write An array of strings with write permissions. By default inherits the existing write permissions. learn more about permissions and get a full list of available permissions.
enabled Is collection enabled?
Response
200
PUT /databases/{databaseId}/collections/{collectionId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]', permission: 'document')
puts response.inspect
Delete Collection
Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.delete_collection(collection_id: '[COLLECTION_ID]')
puts response.inspect
List Attributes
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/attributes
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.list_attributes(collection_id: '[COLLECTION_ID]')
puts response.inspect
Create Boolean Attribute
Create a boolean attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/boolean
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_boolean_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Create Email Attribute
Create an email attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/email
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_email_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Create Enum Attribute
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
elements requiredArray of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/enum
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_enum_attribute(collection_id: '[COLLECTION_ID]', key: '', elements: [], required: false)
puts response.inspect
Create Float Attribute
Create a float attribute. Optionally, minimum and maximum values can be provided.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min Minimum value to enforce on new documents
max Maximum value to enforce on new documents
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/float
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_float_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Create Integer Attribute
Create an integer attribute. Optionally, minimum and maximum values can be provided.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min Minimum value to enforce on new documents
max Maximum value to enforce on new documents
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/integer
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_integer_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Create IP Address Attribute
Create IP address attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/ip
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_ip_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Create String Attribute
Create a string attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
size requiredAttribute size for text attributes, in number of characters.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/string
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_string_attribute(collection_id: '[COLLECTION_ID]', key: '', size: 1, required: false)
puts response.inspect
Create URL Attribute
Create a URL attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
201
POST /databases/{databaseId}/collections/{collectionId}/attributes/url
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_url_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
puts response.inspect
Get Attribute
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
GET /databases/{databaseId}/collections/{collectionId}/attributes/{key}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.get_attribute(collection_id: '[COLLECTION_ID]', key: '')
puts response.inspect
Delete Attribute
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}/attributes/{key}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.delete_attribute(collection_id: '[COLLECTION_ID]', key: '')
puts response.inspect
List Documents
Get a list of all the user's documents in a given collection. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of documents belonging to the provided collectionId. Learn more about different API modes.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.
limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
offset Offset value. The default value is 0. Use this value to manage pagination. learn more about pagination
cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. learn more about pagination
cursorDirection Direction of the cursor, can be either 'before' or 'after'.
orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long.
orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/documents
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.list_documents(collection_id: '[COLLECTION_ID]')
puts response.inspect
Create Document
Create a new Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration. Make sure to define attributes before creating documents.
documentId requiredDocument ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
data requiredDocument data as JSON object.
read An array of strings with read permissions. By default only the current user is granted with read permissions. learn more about permissions and get a full list of available permissions.
write An array of strings with write permissions. By default only the current user is granted with write permissions. learn more about permissions and get a full list of available permissions.
Response
201
POST /databases/{databaseId}/collections/{collectionId}/documents
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {})
puts response.inspect
Get Document
Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
documentId requiredDocument ID.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.get_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]')
puts response.inspect
Update Document
Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
documentId requiredDocument ID.
data Document data as JSON object. Include only attribute and value pairs to be updated.
read An array of strings with read permissions. By default inherits the existing read permissions. learn more about permissions and get a full list of available permissions.
write An array of strings with write permissions. By default inherits the existing write permissions. learn more about permissions and get a full list of available permissions.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]')
puts response.inspect
Delete Document
Delete a document by its unique ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
documentId requiredDocument ID.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.delete_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]')
puts response.inspect
List Indexes
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/indexes
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.list_indexes(collection_id: '[COLLECTION_ID]')
puts response.inspect
Create Index
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
type requiredIndex type.
attributes requiredArray of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
orders Array of index orders. Maximum of 100 orders are allowed.
Response
201
POST /databases/{databaseId}/collections/{collectionId}/indexes
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.create_index(collection_id: '[COLLECTION_ID]', key: '', type: 'key', attributes: [])
puts response.inspect
Get Index
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/indexes/{key}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.get_index(collection_id: '[COLLECTION_ID]', key: '')
puts response.inspect
Delete Index
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}/indexes/{key}
require 'appwrite'
client = Appwrite::Client.new
client
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
.set_project('5df5acd0d48c2') # Your project ID
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
databases = Appwrite::Databases.new(client, database_id:'[DATABASE_ID]')
response = databases.delete_index(collection_id: '[COLLECTION_ID]', key: '')
puts response.inspect