Skip to main content
Module

x/appwrite/mod.ts>Databases

[READ-ONLY] Official Appwrite Deno SDK 🦕
Latest
class Databases
extends Service
Re-export
import { Databases } from "https://deno.land/x/appwrite@10.0.0/mod.ts";

Constructors

new
Databases(client: Client)

Methods

create(
databaseId: string,
name: string,
enabled?: boolean,
): Promise<Models.Database>

Create database

Create a new Database.

createBooleanAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: boolean,
array?: boolean,
): Promise<Models.AttributeBoolean>

Create boolean attribute

Create a boolean attribute.

createCollection(
databaseId: string,
collectionId: string,
name: string,
permissions?: string[],
documentSecurity?: boolean,
enabled?: boolean,
): Promise<Models.Collection>

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.

createDatetimeAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeDatetime>

Create datetime attribute

Create a date time attribute according to the ISO 8601 standard.

createDocument<Document extends Models.Document>(
databaseId: string,
collectionId: string,
documentId: string,
data: object,
permissions?: string[],
): Promise<Document>

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.

createEmailAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeEmail>

Create email attribute

Create an email attribute.

createEnumAttribute(
databaseId: string,
collectionId: string,
key: string,
elements: string[],
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeEnum>

Create enum attribute

Create an enumeration attribute. The elements param acts as a white-list of accepted values for this attribute.

createFloatAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
min?: number,
max?: number,
xdefault?: number,
array?: boolean,
): Promise<Models.AttributeFloat>

Create float attribute

Create a float attribute. Optionally, minimum and maximum values can be provided.

createIndex(
databaseId: string,
collectionId: string,
key: string,
type: IndexType,
attributes: string[],
orders?: string[],
): Promise<Models.Index>

Create index

Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. Attributes can be key, fulltext, and unique.

createIntegerAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
min?: number,
max?: number,
xdefault?: number,
array?: boolean,
): Promise<Models.AttributeInteger>

Create integer attribute

Create an integer attribute. Optionally, minimum and maximum values can be provided.

createIpAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeIp>

Create IP address attribute

Create IP address attribute.

createRelationshipAttribute(
databaseId: string,
collectionId: string,
relatedCollectionId: string,
twoWay?: boolean,
key?: string,
twoWayKey?: string,
onDelete?: RelationMutate,
): Promise<Models.AttributeRelationship>

Create relationship attribute

Create relationship attribute. Learn more about relationship attributes.

createStringAttribute(
databaseId: string,
collectionId: string,
key: string,
size: number,
required: boolean,
xdefault?: string,
array?: boolean,
encrypt?: boolean,
): Promise<Models.AttributeString>

Create string attribute

Create a string attribute.

createUrlAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeUrl>

Create URL attribute

Create a URL attribute.

delete(databaseId: string): Promise<Response>

Delete database

Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.

deleteAttribute(
databaseId: string,
collectionId: string,
key: string,
): Promise<Response>

Delete attribute

Deletes an attribute.

deleteCollection(databaseId: string, collectionId: string): Promise<Response>

Delete collection

Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.

deleteDocument(
databaseId: string,
collectionId: string,
documentId: string,
): Promise<Response>

Delete document

Delete a document by its unique ID.

deleteIndex(
databaseId: string,
collectionId: string,
key: string,
): Promise<Response>

Delete index

Delete an index.

get(databaseId: string): Promise<Models.Database>

Get database

Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata.

getAttribute(
databaseId: string,
collectionId: string,
key: string,
): Promise<Response>

Get attribute

Get attribute by ID.

getCollection(databaseId: string, collectionId: string): Promise<Models.Collection>

Get collection

Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.

getDocument<Document extends Models.Document>(
databaseId: string,
collectionId: string,
documentId: string,
queries?: string[],
): Promise<Document>

Get document

Get a document by its unique ID. This endpoint response returns a JSON object with the document data.

getIndex(
databaseId: string,
collectionId: string,
key: string,
): Promise<Models.Index>

Get index

Get index by ID.

list(queries?: string[], search?: string): Promise<Models.DatabaseList>

List databases

Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.

listAttributes(
databaseId: string,
collectionId: string,
queries?: string[],
): Promise<Models.AttributeList>

List attributes

List attributes in the collection.

listCollections(
databaseId: string,
queries?: string[],
search?: string,
): Promise<Models.CollectionList>

List collections

Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.

listDocuments<Document extends Models.Document>(
databaseId: string,
collectionId: string,
queries?: string[],
): Promise<Models.DocumentList<Document>>

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.

listIndexes(
databaseId: string,
collectionId: string,
queries?: string[],
): Promise<Models.IndexList>

List indexes

List indexes in the collection.

update(
databaseId: string,
name: string,
enabled?: boolean,
): Promise<Models.Database>

Update database

Update a database by its unique ID.

updateBooleanAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: boolean,
): Promise<Models.AttributeBoolean>

Update boolean attribute

Update a boolean attribute. Changing the default value will not update already existing documents.

updateCollection(
databaseId: string,
collectionId: string,
name: string,
permissions?: string[],
documentSecurity?: boolean,
enabled?: boolean,
): Promise<Models.Collection>

Update collection

Update a collection by its unique ID.

updateDatetimeAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
): Promise<Models.AttributeDatetime>

Update dateTime attribute

Update a date time attribute. Changing the default value will not update already existing documents.

updateDocument<Document extends Models.Document>(
databaseId: string,
collectionId: string,
documentId: string,
data?: object,
permissions?: string[],
): Promise<Document>

Update document

Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.

updateEmailAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
): Promise<Models.AttributeEmail>

Update email attribute

Update an email attribute. Changing the default value will not update already existing documents.

updateEnumAttribute(
databaseId: string,
collectionId: string,
key: string,
elements: string[],
required: boolean,
xdefault?: string,
): Promise<Models.AttributeEnum>

Update enum attribute

Update an enum attribute. Changing the default value will not update already existing documents.

updateFloatAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
min: number,
max: number,
xdefault?: number,
): Promise<Models.AttributeFloat>

Update float attribute

Update a float attribute. Changing the default value will not update already existing documents.

updateIntegerAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
min: number,
max: number,
xdefault?: number,
): Promise<Models.AttributeInteger>

Update integer attribute

Update an integer attribute. Changing the default value will not update already existing documents.

updateIpAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
): Promise<Models.AttributeIp>

Update IP address attribute

Update an ip attribute. Changing the default value will not update already existing documents.

updateRelationshipAttribute(
databaseId: string,
collectionId: string,
key: string,
onDelete?: RelationMutate,
): Promise<Models.AttributeRelationship>

Update relationship attribute

Update relationship attribute. Learn more about relationship attributes.

updateStringAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
): Promise<Models.AttributeString>

Update string attribute

Update a string attribute. Changing the default value will not update already existing documents.

updateUrlAttribute(
databaseId: string,
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
): Promise<Models.AttributeUrl>

Update URL attribute

Update an url attribute. Changing the default value will not update already existing documents.