0
Update Document
One script reply has been approved by the moderators Verified
Created by adam186 366 days ago Viewed 4049 times
0
Submitted by adam186 Deno
Verified 366 days ago
1
import {
2
  Client,
3
  Databases,
4
  ID,
5
} from "https://deno.land/x/appwrite@7.0.0/mod.ts";
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
  document_data?: Record<string | number, any>,
19
  document_permissions?: string[],
20
) {
21
  const client = new Client()
22
    .setEndpoint(auth.endpoint)
23
    .setProject(auth.project)
24
    .setKey(auth.key);
25
  const db = new Databases(client);
26

27
  return await db.updateDocument(
28
    database_id,
29
    collection_id,
30
    document_id,
31
    document_data,
32
    document_permissions,
33
  );
34
}
35