Skip to main content
Module

x/appwrite/mod.ts>Database

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

Methods

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

Create Collection

Create a new Collection.

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

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. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents will not be deleted.

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.

listCollections(
search?: string,
limit?: number,
offset?: number,
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,
filters?: string[],
limit?: number,
offset?: number,
orderField?: string,
orderType?: string,
orderCast?: string,
search?: 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.

updateCollection(
collectionId: string,
name: string,
read?: string[],
write?: string[],
rules?: string[],
): 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.