-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
91 lines (71 loc) · 1.75 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import {Dynm} from "../dist/dynm.cjs";
const dynm = new Dynm("Tests", {
dev: true,
// credentials: {
// accessKeyId: "...",
// secretAccessKey: "...",
// },
// primaryKey: "id",
});
async function main() {
const addTable = await dynm.createBaseTable("Tests");
console.log("[CREATE TABLE]:", addTable.ok, "\n");
const addMultiple = await dynm.addBatch([
{
id: "hello",
message: "Hello",
},
{
id: "bye",
message: "Bye",
},
{
id: "allo",
message: "Allo",
},
]);
if (addMultiple.ok) {
console.log("[ADD MULTIPLE] =", addMultiple.value, "\n");
}
const addOne = await dynm.add(
{
id: "hello",
colorful: true,
message: "Hello",
canBeBroadcasted: false,
},
true
);
if (addOne.ok) {
console.log("[ADD] ID: hello =", addOne.value, "\n");
}
const all = await dynm.all();
if (all.ok) {
const {Count, Items} = all.value;
console.log("[ALL] Count:", Count, "Items =", Items, "\n");
}
const getOne = await dynm.get("hello");
if (getOne.ok) {
console.log("[GET] ID: hello =", getOne.value.Item, "\n");
}
const getMultiple = await dynm.getBatch(["hello", "bye"]);
if (getMultiple.ok) {
console.log("[GET MULTIPLE] =", getMultiple.value.Responses, "\n");
}
const up = await dynm.update("hello", {
afterUpdate: true,
});
if (up.ok) {
console.log("[UPDATE] ID: hello =", up.value, "\n");
}
const deleteOne = await dynm.delete("hello");
if (deleteOne.ok) {
console.log("[DELETE] ID: hello", "\n");
}
const allAfterDelete = await dynm.all();
if (allAfterDelete.ok) {
const {Count, Items} = allAfterDelete.value;
console.log("[ALL] Count:", Count, "Items =", Items, "\n");
}
}
main();