-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.sql
64 lines (46 loc) · 1.79 KB
/
query.sql
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
-- name: InsertItem :exec
INSERT INTO items (
id, deleted, type, by, time, text, dead, parent, poll, url, score, title, descendants
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
);
-- name: GetItem :one
SELECT * from items where id = ?;
-- name: GetItemsWithTitle :many
select * from items where title like ? order by id desc;
-- name: GetPostCount :one
select count(*) from items where parent = 0;
-- name: GetItemCount :one
select count(*) from items;
-- name: GetItems :many
SELECT * from items where id in (sqlc.slice('ids'));
-- name: UpdateItem :exec
UPDATE items set parent = ?, time = ?, type = ?, by = ? where id = ?;
-- name: PaginateItems :many
SELECT * from items where id > ? order by id limit ?;
-- name: GetItemsForParent :many
SELECT * from items where parent = ? order by id;
-- name: GetPosts :many
select * from items where parent is null order by id desc;
-- name: GetKidsForItems :many
SELECT * from item_kids where item_id in (sqlc.slice('ids'));
-- name: GetEmbedding :one
select * from embeddings where item_id = ? and model = ?;
-- name: InsertEmbedding :exec
INSERT INTO embeddings(
item_id, model, embedding, created_at, updated_at
) VALUES(
?, ?, ?, ?, ?
);
-- name: GetEmbeddingsByParent :many
select * from embeddings where model = ? and item_id in (select id from items where parent = ?);
-- name: GetEmbeddings :many
select * from embeddings where model = ? and item_id in (sqlc.slice('ids'));
-- name: InsertItemKids :exec
INSERT INTO item_kids (item_id, kid_id) VALUES (?, ?);
-- name: InsertItemParts :exec
INSERT INTO item_parts (item_id, part_id) VALUES (?, ?);
-- name: GetLinkedInScrape :one
select * from linkedin_scrapes where url = ?;
-- name: InsertLinkedInScrape :exec
INSERT INTO linkedin_scrapes (url, json, created_at, updated_at) VALUES (?, ?, ?, ?);