-
Notifications
You must be signed in to change notification settings - Fork 0
/
initKv.ts
46 lines (39 loc) · 1.04 KB
/
initKv.ts
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
const kv = await Deno.openKv(
"https://api.deno.com/databases/8224906d-742a-4220-9a66-638bf8d37da3/connect",
);
interface notifId {
id: string;
dataId: string;
}
async function initKv() {
try {
const f = await fetch(`${Deno.env.get("GTS_API")}`, {
method: "GET",
headers: {
"Content-Type": "Application/json",
Authorization: `Bearer ${Deno.env.get("GTS_TOKEN")}`,
},
});
const data = await f.json();
const data_id = [];
for await (const d of data) data_id.push(d.id);
const kvData = kv.list({ prefix: ["notif_id"] });
const kvDataId = [];
for await (const k of kvData) kvDataId.push(k.value);
for (const v of kvDataId) {
const x = data_id.includes(v);
if (x == true) {
console.log("break");
}
}
// for (const di of data_id) {
// const res = await kv.set(["notif_id", di], di);
// if (res.ok == false) {
// throw new Error(`tidak bisa menulis ke KV!`);
// }
// }
} catch (e) {
console.log(e);
}
}
initKv();