-
Notifications
You must be signed in to change notification settings - Fork 0
/
appwrite-links.js
53 lines (47 loc) · 1.08 KB
/
appwrite-links.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require("dotenv").config();
const sdk = require("node-appwrite");
const client = new sdk.Client();
client
.setEndpoint("http://localhost:3000/v1") // Your API Endpoint
.setProject(process.env.PROJECT_ID) // Your project ID
.setKey(process.env.APPWRITE_KEY); // Your secret API key
const db = new sdk.Database(client);
const run = async () => {
try {
let collection = await db.createCollection(
"Links",
[],
[],
[
{
label: "originalURL",
key: "originalurl",
type: "text",
default: "Empty Name",
required: true,
array: false,
},
{
label: "uniqueName",
key: "uniquename",
type: "text",
default: "Empty",
required: true,
array: false,
},
{
label: "shortUrl",
key: "shorturl",
type: "text",
default: "Empty",
required: true,
array: false,
},
]
);
console.log(collection.$id);
} catch (e) {
console.log(e);
}
};
run();