-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.js
51 lines (36 loc) · 972 Bytes
/
hello.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
import { Hono } from "https://deno.land/x/[email protected]/mod.ts";
//import { serveStatic } from "https://deno.land/x/[email protected]/middleware.ts"
import Surreal from "https://deno.land/x/[email protected]/mod.ts";
const app = new Hono();
const db = new Surreal("http://127.0.0.1:8000/rpc");
async function main(){
try{
await db.signin({
user: 'root',
pass: 'root',
});
await db.use({ ns: "testuje", db: "test"});
const existingData = await db.select("osoba");
if (!existingData || existingData.length === 0) {
console.log("Dodawanie oosby");
db.create("osoba",{
tytul: "Inż",
name: {
imie: "Michal",
nazwisko: "Czachowski",
},
m: true,
id: 1,
})
}
else{
console.log("Osoba jest już dodana");
}
const data = await db.select("osoba");
console.log(data);
}
catch (e) {
console.error("ERROR", e);
}
}
main()