Abstract rules - NonStopGreen/tag-sorter GitHub Wiki
Abstract rules
This page is a collection of rules for tag-sorter
Rule 1: .find(), .sort() and .limit() should come before .exec()
Rule 2: followedTags and ignoredTags should be an array with strings
Good tag sorting vs bad tag sorting
Bad tag sorting
var tag = new Tag({
documents: documents // Array of documents
});
var documents = tag.find({ watchedTags: fullStack, ignoredTags: jqueryHater }).exec().documents;
var countedTags = tag.find({ watchedTags: fullStack, ignoredTags: jqueryHater }).exec().countedTags;
var uniqueTags= tag.find({ watchedTags: fullStack, ignoredTags: jqueryHater }).exec().uniqueTags;
Good tag sorting
var tag = new Tag({
documents: documents // Array of documents
});
var { documents, countedTags, uniqueTags } = tag.find({ watchedTags: fullStack, ignoredTags: jqueryHater }).exec();
// This is good because you call .exec() only one time
// Faster than the bad code
More rules coming soon...