A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://appwrite.io/docs/references/cloud/client-web/databases below:

Databases API Reference - Docs

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://<REGION>.cloud.appwrite.io/v1
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.

POST /databases/{databaseId}/collections/{collectionId}/documents
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.createDocument(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    {}, 
    ["read("any")"] 
);

console.log(result);
Get document

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

GET /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.getDocument(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    [] 
);

console.log(result);
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.

GET /databases/{databaseId}/collections/{collectionId}/documents
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.listDocuments(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    [] 
);

console.log(result);
Update document

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

PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.updateDocument(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    {}, 
    ["read("any")"] 
);

console.log(result);
Delete document

Delete a document by its unique ID.

DELETE /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.deleteDocument(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>' 
);

console.log(result);
Decrement document attribute

Decrement a specific attribute of a document by a given value.

PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.decrementDocumentAttribute(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    '', 
    null, 
    null 
);

console.log(result);
Increment document attribute

Increment a specific attribute of a document by a given value.

PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.incrementDocumentAttribute(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    '', 
    null, 
    null 
);

console.log(result);
Upsert document

WARNING: Experimental Feature - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.

Create or update a Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.

PUT /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>'); 

const databases = new Databases(client);

const result = await databases.upsertDocument(
    '<DATABASE_ID>', 
    '<COLLECTION_ID>', 
    '<DOCUMENT_ID>', 
    {}, 
    ["read("any")"] 
);

console.log(result);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4