Update Collection

Script appwrite Verified

by adam186 ยท 4/17/2023

The script

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

3
type Appwrite = {
4
  endpoint: string;
5
  project: string;
6
  key: string;
7
  self_signed: boolean;
8
};
9
export async function main(
10
  auth: Appwrite,
11
  database_id: string,
12
  collection_name: string,
13
  collection_id: string,
14
  collection_permissions?: string[],
15
  collection_document_security?: boolean,
16
  collection_enabled?: boolean,
17
) {
18
  const client = new Client()
19
    .setEndpoint(auth.endpoint)
20
    .setProject(auth.project)
21
    .setKey(auth.key);
22
  const db = new Databases(client);
23

24
  return await db.updateCollection(
25
    database_id,
26
    collection_id,
27
    collection_name,
28
    collection_permissions,
29
    collection_document_security,
30
    collection_enabled,
31
  );
32
}
33

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
    type Appwrite = {
    4
      endpoint: string;
    5
      project: string;
    6
      key: string;
    7
      self_signed: boolean;
    8
    };
    9
    export async function main(
    10
      auth: Appwrite,
    11
      database_id: string,
    12
      collection_name: string,
    13
      collection_id: string,
    14
      collection_permissions?: string[],
    15
      collection_document_security?: boolean,
    16
      collection_enabled?: boolean,
    17
    ) {
    18
      const client = new Client()
    19
        .setEndpoint(auth.endpoint)
    20
        .setProject(auth.project)
    21
        .setKey(auth.key);
    22
      const db = new Databases(client);
    23
    
    
    24
      return await db.updateCollection(
    25
        database_id,
    26
        collection_id,
    27
        collection_name,
    28
        collection_permissions,
    29
        collection_document_security,
    30
        collection_enabled,
    31
      );
    32
    }
    33