-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsqlite3_stmts.go
67 lines (55 loc) · 1.71 KB
/
sqlite3_stmts.go
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
package main
const CreateTokenTable = `
CREATE TABLE IF NOT EXISTS token (
label PRIMARY KEY,
pin TEXT,
so_pin TEXT
)`
const InsertTokenQuery = `
INSERT OR REPLACE INTO token (label, pin, so_pin) VALUES (?, ?, ?)
`
const GetTokenQuery = `
SELECT pin, so_pin
FROM token
WHERE label = ?
`
const CreateCryptoObjectTable = `
CREATE TABLE IF NOT EXISTS crypto_object (
token_label TEXT,
handle INTEGER,
PRIMARY KEY (token_label, handle)
)`
const InsertCryptoObjectQuery = `
INSERT OR IGNORE INTO crypto_object (token_label, handle)
VALUES (?, ?)
`
const CleanCryptoObjectQuery = `
DELETE FROM crypto_object WHERE token_label = ?
`
const GetCryptoObjectAttrsQuery = `
SELECT co.handle, att.type, att.value
FROM crypto_object as co
LEFT JOIN attribute as att
ON att.token_label = co.token_label
AND att.crypto_object_handle = co.handle
WHERE co.token_label = ?
`
const CreateAttributeTable = `
CREATE TABLE IF NOT EXISTS attribute (
token_label TEXT,
crypto_object_handle INTEGER,
type INTEGER,
value BLOB,
PRIMARY KEY (token_label, crypto_object_handle, type)
)`
const InsertAttributeQuery = `
INSERT OR REPLACE INTO attribute (token_label, crypto_object_handle, type, value)
VALUES (?, ?, ?, ?)
`
const CleanAttributesQuery = `
DELETE FROM attribute WHERE token_label = ?
`
const GetMaxHandleQuery = `
SELECT MAX(handle) FROM crypto_object
`
var CreateStmts = []string{CreateTokenTable, CreateCryptoObjectTable, CreateAttributeTable}