-
Notifications
You must be signed in to change notification settings - Fork 0
/
gabastats.nb.ts
24 lines (19 loc) · 1.07 KB
/
gabastats.nb.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
//#nbts@code
import Surreal, {
RecordId,
} from "https://deno.land/x/[email protected]/mod.ts";
let db = new Surreal();
await db.connect("http://127.0.0.1:8000/rpc", {
namespace: "drugs",
database: "drugs",
});
//#nbts@code
let p = await db.query(/* surrealql */ `select name, (select name, actions from targets.target) as target from drugs where "Anticonvulsants" in categories.category.category split target`);
p = p[0]; p
//#nbts@code
let p = await db.query(/* surrealql */ `select target, count(name), array::distinct(name) as meds from (select name, (select name, actions from targets.target) as target from drugs where "Anticonvulsants" in categories.category.category split target) group by target order by count desc`);
p = p[0]; p
//#nbts@code
let p = await db.query(/* surrealql */ `select target, count(name), array::distinct(name) as meds from (select name, (select name, actions from targets.target) as target from drugs where "Anti-Anxiety Agents" in categories.category.category split target) group by target order by count desc`);
p = p[0]; p
//#nbts@code