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@0.4.0/src/services/database.ts";

Methods

createCollection<T extends unknown>(
name: string,
read: string[],
write: string[],
rules: string[],
): Promise<T>

Create Collection

Create a new Collection.

createDocument<T extends unknown>(
collectionId: string,
data: object,
read?: string[],
write?: string[],
parentDocument?: string,
parentProperty?: string,
parentPropertyType?: string,
): Promise<T>

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.

deleteCollection<T extends unknown>(collectionId: string): Promise<T>

Delete Collection

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

deleteDocument<T extends unknown>(collectionId: string, documentId: string): Promise<T>

Delete Document

Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents will not be deleted.

getCollection<T extends unknown>(collectionId: string): Promise<T>

Get Collection

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

getDocument<T extends unknown>(collectionId: string, documentId: string): Promise<T>

Get Document

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

listCollections<T extends unknown>(
search?: string,
limit?: number,
offset?: number,
orderType?: string,
): Promise<T>

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<T extends unknown>(
collectionId: string,
filters?: string[],
limit?: number,
offset?: number,
orderField?: string,
orderType?: string,
orderCast?: string,
search?: string,
): Promise<T>

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.

updateCollection<T extends unknown>(
collectionId: string,
name: string,
read?: string[],
write?: string[],
rules?: string[],
): Promise<T>

Update Collection

Update a collection by its unique ID.

updateDocument<T extends unknown>(
collectionId: string,
documentId: string,
data: object,
read?: string[],
write?: string[],
): Promise<T>

Update Document

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