MongoDB commenting system Slug, What is it for?

Basically a slug is nothing more than a "part of a URL which identifies" an object "using human-readable keywords" (see Wikipedia "Semantic URL")

In the MongoDB use case document "Storing Comments" each comment gets a unique short "slug part" which can be considered as a kind of alternative, database independent ID. The slug field of the comment document is then built by chaining all slug parts of all comments alongside the discussion thread hierarchy to form a path to the actual comment. Basically it could also be built by joining the string representations of the IDs of all (parent) comments delimited by slashes. But then it would be much longer, less human readable and to some degree more dependent from the underlying MongoDB database.

The full_slug field is formed like the slug as described above but each slug part is prefixed with the date and time of creation of its related comment. This seems to be necessary or at least advantageous to perform sorted queries by discussion thread and date at once. The full_slug field is arranged just for the implementation of queries sorted by discussion thread and date.


One thing is like the answer above. But i think they have also another ussage.

For commenting system that required threaded comments (like reply to a comment), you need this "slug" stuffs in order to be able to sort the retrieved comments by 'full_slug'.

Resulted in an array of comments that sorted by threaded order. In the frontend, you can displayed them with different indent.


For my opinion, it looks like some kind of a URL shortcut to get the comments, for example, when you type: http://site.com/34db/8bda it will bring you the comment itself, the full-slug is for sorting and ordering the comments by the time they posted.

Tags:

Slug

Mongodb