0
Create Database
One script reply has been approved by the moderators Verified
Created by adam186 614 days ago Viewed 9197 times
0
Submitted by adam186 Deno
Verified 614 days ago
1
import {
2
  Client,
3
  Databases,
4
  ID,
5
} from "https://deno.land/x/appwrite@7.0.0/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