Create Database

Script appwrite Verified

by adam186 ยท 4/17/2023

The script

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

3
/**
4
 * @param id ID of the user to be created. Leave blank to generate a unique ID.
5
 */
6
type Appwrite = {
7
  endpoint: string;
8
  project: string;
9
  key: string;
10
  self_signed: boolean;
11
};
12
export async function main(auth: Appwrite, name: string, id?: string) {
13
  const client = new Client()
14
    .setEndpoint(auth.endpoint)
15
    .setProject(auth.project)
16
    .setKey(auth.key);
17
  const db = new Databases(client);
18

19
  return await db.create(id || ID.unique(), name);
20
}
21

Other submissions
  • Submitted by adam186 Deno
    Created 393 days ago
    1
    import {
    2
      Client,
    3
      Databases,
    4
      ID,
    5
    } from "https://deno.land/x/[email protected]/mod.ts";
    6
    
    
    7
    /**
    8
     * @param id ID of the user to be created. Leave blank to generate a unique ID.
    9
     */
    10
    type Appwrite = {
    11
      endpoint: string;
    12
      project: string;
    13
      key: string;
    14
      self_signed: boolean;
    15
    };
    16
    export async function main(auth: Appwrite, name: string, id?: string) {
    17
      const client = new Client()
    18
        .setEndpoint(auth.endpoint)
    19
        .setProject(auth.project)
    20
        .setKey(auth.key);
    21
      const db = new Databases(client);
    22
    
    
    23
      return await db.create(id || ID.unique(), name);
    24
    }
    25