Get Document

Script appwrite Verified

by adam186 ยท 4/18/2023

The script

Submitted by hugo989 Bun
Verified 1 day ago
1
import { Client, Databases } from "[email protected]";
2

3
/**
4
 * @param queries Array of query strings. Learn more about queries here:
5
 * https://appwrite.io/docs/queries
6
 */
7
type Appwrite = {
8
  endpoint: string;
9
  project: string;
10
  key: string;
11
  self_signed: boolean;
12
};
13
export async function main(
14
  auth: Appwrite,
15
  database_id: string,
16
  collection_id: string,
17
  document_id: string,
18
  queries?: string[],
19
) {
20
  const client = new Client()
21
    .setEndpoint(auth.endpoint)
22
    .setProject(auth.project)
23
    .setKey(auth.key);
24
  const db = new Databases(client);
25

26
  return await db.getDocument(database_id, collection_id, document_id, queries);
27
}
28

Other submissions
  • Submitted by adam186 Deno
    Created 393 days ago
    1
    import { Client, Databases } from "https://deno.land/x/[email protected]/mod.ts";
    2
    
    
    3
    /**
    4
     * @param queries Array of query strings. Learn more about queries here:
    5
     * https://appwrite.io/docs/queries
    6
     */
    7
    type Appwrite = {
    8
      endpoint: string;
    9
      project: string;
    10
      key: string;
    11
      self_signed: boolean;
    12
    };
    13
    export async function main(
    14
      auth: Appwrite,
    15
      database_id: string,
    16
      collection_id: string,
    17
      document_id: string,
    18
      queries?: string[],
    19
    ) {
    20
      const client = new Client()
    21
        .setEndpoint(auth.endpoint)
    22
        .setProject(auth.project)
    23
        .setKey(auth.key);
    24
      const db = new Databases(client);
    25
    
    
    26
      return await db.getDocument(database_id, collection_id, document_id, queries);
    27
    }
    28