0

Update Doc

by
Published Mar 4, 2023

Update document

Script AppWrite
  • Submitted by said30 Deno
    Created 1227 days ago
    1
    import * as sdk from "https://deno.land/x/[email protected]/mod.ts";
    2
    import type { Resource } from "https://deno.land/x/[email protected]/mod.ts";
    3
    
    
    4
    export async function main(
    5
        auth: Resource<"appwrite">,
    6
        databaseId: string,
    7
        collectionId: string,
    8
        documentId: string,
    9
        data: object,
    10
    ) 
    11
    {
    12
    
    
    13
      console.log("data to update");
    14
      console.log(data);
    15
      let client = new sdk.Client();
    16
      client
    17
          .setEndpoint(auth.endpoint) // Your API Endpoint
    18
          .setProject(auth.project) // Your project ID
    19
          .setKey(auth.key) // Your secret API key
    20
    
    
    21
      const databases = new sdk.Databases(client);
    22
    
    
    23
      return await databases.updateDocument
    24
      (
    25
        databaseId,
    26
        collectionId,
    27
        documentId,
    28
        data
    29
      )
    30
    }
    31