Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/appwrite/src/services/database.ts>Database

[READ-ONLY] Official Appwrite Deno SDK 🦕
Go to Latest
class Database
extends Service
import { Database } from "https://deno.land/x/appwrite@4.0.0/src/services/database.ts";

Methods

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

Create Boolean Attribute

Create a boolean attribute.

createCollection(
collectionId: string,
name: string,
permission: string,
read: string[],
write: string[],
): Promise<Models.Collection>

Create Collection

Create a new Collection.

createDocument<Document extends Models.Document>(
collectionId: string,
documentId: string,
data: object,
read?: string[],
write?: 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(
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeEmail>

Create Email Attribute

Create an email attribute.

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

Create Enum Attribute

createFloatAttribute(
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(
collectionId: string,
key: string,
type: string,
attributes: string[],
orders?: string[],
): Promise<Models.Index>

Create Index

createIntegerAttribute(
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(
collectionId: string,
key: string,
required: boolean,
xdefault?: string,
array?: boolean,
): Promise<Models.AttributeIp>

Create IP Address Attribute

Create IP address attribute.

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

Create String Attribute

Create a string attribute.

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

Create URL Attribute

Create a URL attribute.

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

Delete Attribute

deleteCollection(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(collectionId: string, documentId: string): Promise<Response>

Delete Document

Delete a document by its unique ID.

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

Delete Index

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

Get Attribute

getCollection(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>(collectionId: string, documentId: string): Promise<Document>

Get Document

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

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

Get Index

listAttributes(collectionId: string): Promise<Models.AttributeList>

List Attributes

listCollections(
search?: string,
limit?: number,
offset?: number,
cursor?: string,
cursorDirection?: string,
orderType?: string,
): Promise<Models.CollectionList>

List Collections

Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's collections. Learn more about different API modes.

listDocuments<Document extends Models.Document>(
collectionId: string,
queries?: string[],
limit?: number,
offset?: number,
cursor?: string,
cursorDirection?: string,
orderAttributes?: string[],
orderTypes?: string[],
): Promise<Models.DocumentList<Document>>

List Documents

Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's documents. Learn more about different API modes.

listIndexes(collectionId: string): Promise<Models.IndexList>

List Indexes

updateCollection(
collectionId: string,
name: string,
permission: string,
read?: string[],
write?: string[],
enabled?: boolean,
): Promise<Models.Collection>

Update Collection

Update a collection by its unique ID.

updateDocument<Document extends Models.Document>(
collectionId: string,
documentId: string,
data: object,
read?: string[],
write?: 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.