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 |
|