-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
71 lines (61 loc) · 1.82 KB
/
example.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const CherrryClient = require("./index");
const private_key = "your_private_key";
const client = new CherrryClient(private_key);
const createTableTest = async () => {
var { success, error } = await client.create_table("doc-sections");
console.log("create table error::", success);
console.log("error::", error);
};
const insertTest = async () => {
var { data, error } = await client.from("blogs").insert({
text: {
title: "Grey's Anatomy"
},
image: {
banner: "https://i.imgur.com/rCi9ooQ.jpeg"
},
metadata: {
author_name: "Kermit The Frog",
author_email: "frog@dog.com"
}
});
var { data, error } = await client.from("blogs").insert({
text: {
title: "Octopus Cherry Pie"
},
image: {
banner: "https://i.imgur.com/lFC8p0L.jpeg"
},
data: {
author_name: "Davy Jones",
author_email: "octo@pus.com"
}
});
console.log("insert::", data);
console.log("error::", error);
};
const searchTest = async () => {
var { data, error } = await client
.from("docs")
.search({ prompt: "python", size: 3, search_type: "text" });
console.log("search::", data);
console.log("error::", error);
};
const docTest = async () => {
var { data, error } = await client.from("blogs").doc("6423958");
console.log("doc::", data);
console.log("error::", error);
};
const deleteTest = async () => {
var { success, error } = await client.from("blogs").delete("6423958");
console.log("delete::", success);
console.log("error::", error);
};
const run = async () => {
// await createTableTest();
// await insertTest();
// await searchTest();
// await docTest();
// await deleteTest();
};
run();