-
Notifications
You must be signed in to change notification settings - Fork 0
Posts
Posts are pretty simple objects. Here is a quick overview of their structure.
Since Telescope uses MongoDB, a lot of data is denormalized, which simply means it can appear in multiple place.
A good example would be the number of comments: we could get it from a simple "count" database query on the comments collection, but we also store it on each post object to avoid having to redo that operation every time we display a post.
Also due to MongoDB being NoSQL, do not expect every single post to have the exact same data structure. Some properties can end up being left blank or not existing for some posts.
_id: "a05eba73-cdd9-4d64-933d-2586ffc58739"
author: "Sacha Greif"
baseScore: 119
body: ""
categories: Array[0]
comments: 77
headline: "Introducing Telescope"
inactive: false
score: 0.013237893608981862
status: 2
sticky: true
submitted: 1354079460000
upvoters: Array[115]
url: "http://sachagreif.com/introducing-telescope/"
userId: "e68e20f6-f313-467f-8bad-5ef9737d631e"
votes: 115
The MongoDB ID.
The name of the author, denormalized into the post object for faster access according to MongoDB best practices.
The total number of points this post has received up to now.
Post contents.
An array of the categories assigned to the post.
The number of comments this post has received.
Timestamp of the post creation.
An array of the user ids of people who have downvoted the post.
Post headline.
A flag that is set when posts are older than a certain length of time. Inactive posts get their score recalculated less often.
Upvoting/downvoting a post automatically sets the flag to false until the next scoring cycle.
The final score used to rank posts. Depends both on the baseScore
and the time from submission, and is recalculated an regular intervals.
Posts can be Pending (status = 1), Approved (status = 2), or Rejected (status = 3). Depending your settings, this can affect how a post is displayed publicly.
Sticky posts are always shown at the top of the list.
The submitted timestamp indicates the time a post first appeared on the site, i.e. the time a pending post was first marked as approved. Telescope almost always uses this timestamp rather than createdAt
.
Note that when post approval is not necessary, this is set at the same time as createdAt
.
An array of the user ids of people who have upvoted the post.
The id of the post author.
The number of votes the post has received.