-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.ts
55 lines (49 loc) · 1016 Bytes
/
proxy.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
import { proxySchema } from 'better-sqlite3-proxy'
import { db } from './db'
export type Keyword = {
id?: null | number
keyword: string
complete_time: null | number
}
export type Domain = {
id?: null | number
domain: string
}
export type Page = {
id?: null | number
url: string
domain_id: number
domain?: Domain
}
export type Image = {
id?: null | number
page_id: null | number
page?: Page
filename: string
keyword_id: null | number
keyword?: Keyword
alt: null | string
embedding: null | string
}
export type DBProxy = {
keyword: Keyword[]
domain: Domain[]
page: Page[]
image: Image[]
}
export let proxy = proxySchema<DBProxy>({
db,
tableFields: {
keyword: [],
domain: [],
page: [
/* foreign references */
['domain', { field: 'domain_id', table: 'domain' }],
],
image: [
/* foreign references */
['page', { field: 'page_id', table: 'page' }],
['keyword', { field: 'keyword_id', table: 'keyword' }],
],
},
})