The Wayback Machine - https://web.archive.org/web/20200706142635/https://github.com/NodeBB/NodeBB/issues/7744
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: document data structures used in NodeBB #7744

Open
BenLubar opened this issue Jul 9, 2019 · 1 comment
Open

Task: document data structures used in NodeBB #7744

BenLubar opened this issue Jul 9, 2019 · 1 comment

Comments

@BenLubar
Copy link
Contributor

@BenLubar BenLubar commented Jul 9, 2019

We really need to document data structures in the database. Ideally, in some format that is machine-readable, but at least for the benefit of humans.

For example, here's what (partial, missing fields not added to newly-created topics) definitions of the "topic" and "post" data types in the database looks like.

OBJECT hash, topic:{tid}
KEY hash, global, nextTid, tid
FIELD String, title
FIELD String, slug
FIELD Number, uid
FIELD Number, cid
FIELD Number, mainPid
FIELD Date, timestamp
FIELD Date, lastposttime
FIELD Number, postcount
FIELD Number, viewcount
FIELD Boolean, locked
FIELD Boolean, deleted
PRIMARY zset, topics:tid, {timestamp}, {tid}
INDEX zset, topics:recent, {lastposttime}, {tid}
INDEX zset, cid:{cid}:tids, {lastposttime}, {tid}
INDEX zset, cid:{cid}:uid:{uid}:tids, {timestamp}, {tid}
INDEX zset, uid:{uid}:topics, {timestamp}, {tid}
INDEX zset, cid:{cid}:recent_tids, {timestamp}, {tid}
INDEX zset, cid:{cid}:tids:lastposttime, {timestamp}, {tid}
INDEX zset, topics:posts, {postcount}, {tid}
INDEX zset, cid:{cid}:tids:posts, {postcount}, {tid}
COUNTER hash, global, topicCount
COUNTER hash, category:{cid}, topic_count, {cid}
COUNTER hash, user:{uid}, topiccount, {uid}
FOREIGN hash, post:{mainPid}
FOREIGN hash, user:{uid}
FOREIGN hash, category:{cid}

OBJECT hash, post:{pid}
KEY hash, global, nextPid, pid
FIELD Number, uid
FIELD Number, tid
FIELD Number, upvotes
FIELD Number, downvotes
FIELD String, content
FIELD Date, timestamp
FIELD Boolean, deleted
COMPUTED votes, expr, ({upvotes} - {downvotes})
COMPUTED cid, hash, topic:{tid}, cid
PRIMARY zset, posts:pid, {timestamp}, {pid}
INDEX zset, cid:{cid}:tids:votes, {votes}, {tid}
INDEX zset, uid:{uid}:posts, {timestamp}, {pid}
INDEX zset, cid:{cid}:uid:{uid}:pids, {timestamp}, {pid}
INDEX zset, cid:{cid}:pids, {timestamp}, {pid}
COUNTER hash, global, postCount
COUNTER hash, user:{uid}, postcount, {uid}
COUNTER hash, topic:{tid}, postcount, {tid}
COUNTER hash, category:{cid}, post_count, {cid}
COUNTER zset, tid:{tid}:posters, {uid}, {tid}
MAX hash, topic:{tid}, lastposttime, {timestamp}
MAX hash, user:{uid}, lastposttime, {timestamp}
FOREIGN hash, user:{uid}
FOREIGN hash, topic:{tid}

Describing all data types is the first step of many future database-related improvements, such as automatic pseudo-index and counter repairs and moving away from the Redis database emulation layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.