forked from HelloZeroNet/ZeroMe
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dbschema.json
108 lines (108 loc) · 3.42 KB
/
dbschema.json
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
"db_name": "ZeroMe",
"db_file": "merged-ZeroMe/ZeroMe.db",
"version": 3,
"maps": {
".+/data/userdb/.+/content.json": {
"to_json_table": [ "cert_auth_type", "cert_user_id" ],
"to_table": ["user"]
},
".+/data/userdb/users.json": {
"to_table": ["user"]
},
".+/data/users/.+/content.json": {
"to_json_table": [ "cert_auth_type", "cert_user_id" ],
"file_name": "data.json"
},
".+/data/users/.+/data.json": {
"to_table": [
"post",
"comment",
"follow",
{"node": "post_like", "table": "post_like", "key_col": "post_uri", "val_col": "date_added"}
],
"to_json_table": [ "hub", "user_name", "avatar", "intro", "bg", "bgColor" ]
}
},
"tables": {
"json": {
"cols": [
["json_id", "INTEGER PRIMARY KEY AUTOINCREMENT"],
["site", "TEXT"],
["directory", "TEXT"],
["file_name", "TEXT"],
["cert_auth_type", "TEXT"],
["cert_user_id", "TEXT"],
["hub", "TEXT"],
["user_name", "TEXT"],
["intro", "TEXT"],
["avatar", "TEXT"],
["bg", "TEXT"],
["bgColor", "TEXT"]
],
"indexes": ["CREATE UNIQUE INDEX path ON json(directory, site, file_name)"],
"schema_changed": 5
},
"post": {
"cols": [
["post_id", "INTEGER"],
["body", "TEXT"],
["meta", "TEXT"],
["date_added", "INTEGER"],
["json_id", "INTEGER REFERENCES json (json_id)"]
],
"indexes": ["CREATE UNIQUE INDEX post_key ON post(json_id, post_id)", "CREATE INDEX post_id ON post(post_id)", "CREATE INDEX added ON post(date_added)"],
"schema_changed": 4
},
"post_like": {
"cols": [
["post_uri", "TEXT"],
["date_added", "INTEGER"],
["json_id", "INTEGER REFERENCES json (json_id)"]
],
"indexes": ["CREATE UNIQUE INDEX post_like_key ON post_like(json_id, date_added)", "CREATE INDEX post_uri ON post_like(post_uri)"],
"schema_changed": 1
},
"comment": {
"cols": [
["comment_id", "INTEGER"],
["post_uri", "TEXT"],
["body", "TEXT"],
["date_added", "INTEGER"],
["json_id", "INTEGER REFERENCES json (json_id)"]
],
"indexes": ["CREATE UNIQUE INDEX comment_key ON comment(json_id, comment_id)", "CREATE INDEX comment_post_uri ON comment(post_uri)"],
"schema_changed": 2
},
"follow": {
"cols": [
["follow_id", "INTEGER"],
["user_name", "TEXT"],
["auth_address", "TEXT"],
["hub", "TEXT"],
["date_added", "INTEGER"],
["json_id", "INTEGER REFERENCES json (json_id)"]
],
"indexes": ["CREATE UNIQUE INDEX follow_key ON follow(json_id, follow_id)"],
"schema_changed": 2
},
"user": {
"cols": [
["auth_address", "TEXT"],
["cert_user_id", "TEXT"],
["hub", "TEXT"],
["user_name", "TEXT"],
["avatar", "TEXT"],
["intro", "TEXT"],
["date_added", "INTEGER"],
["json_id", "INTEGER REFERENCES json (json_id)"]
],
"indexes": ["CREATE INDEX json_id ON user(json_id)", "CREATE INDEX date_added ON user(date_added)"],
"schema_changed": 3
}
},
"feeds": {
"Posts": "SELECT 'post' AS type, post.date_added AS date_added, 'In ' || json.user_name || \"'s post\" AS title, post.body AS body, '?Post/' || json.site || '/' || REPLACE(json.directory, 'data/users/', '') || '/' || post_id AS url FROM post LEFT JOIN json USING (json_id)",
"Comments": "SELECT 'comment' AS type, comment.date_added AS date_added, 'a post' AS title, '@' || user_name || ': ' || comment.body AS body, '?Post/' || json.site || '/' || REPLACE(post_uri, '_', '/') AS url FROM comment LEFT JOIN json USING (json_id)"
}
}