Find all documents - NonStopGreen/tag-sorter GitHub Wiki
How to find all documents with .find({ watchedTags })
varTag=require('../index.js');// Data taken from stackoverflow.comvardocuments=[{title: "How can I remove a specific item from an array?",tags: ["javascript","arrays"]},{title: 'How do I check if an element is hidden in jQuery?',tags: ['javascript','jquery','dom',"visibility"]},{title: 'How do I redirect to another webpage?',tags: ['javascript','jquery','redirect']},{title: 'How do JavaScript closures work?',tags: ['javascript','function','variables','scope','closures']},{title: 'What does “use strict” do in JavaScript, and what is the reasoning behind it?',tags: ['javascript',"syntax","jslint","use-strict"]},{title: 'How to check whether a string contains a substring in JavaScript?',tags: ["javascript","string","substring","string-matching"]},{title: "var functionName = function() {} vs function functionName() {}",tags: ['javascript','function',"syntax","idioms"]},{title: 'How do I remove a property from a JavaScript object?',tags: ["javascript","javascript-objects"]},{title: "Which equals operator (== vs ===) should be used in JavaScript comparisons?",tags: ["javascript","operators","equality","equality-operator","identity-operator"]},{title: "How do I return the response from an asynchronous call?",tags: ["javascript","jquery","ajax","asynchronous"]},{title: "Why does HTML think “chucknorris” is a color?",tags: ["html","browser","background-color"]},{title: "How do I check whether a checkbox is checked in jQuery?",tags: ["javascript","jquery","html","checkbox"]},{title: "How to horizontally center a <div>",tags: ["html","css","alignment","centering"]}];// Followed tagsvarnoobie=["html","css"];varfullStack=["html","css","javascript","node.js","mongoose"];varjqueryFan=["jquery"];// Ignored TagsvarfrontendHater=["html","css"];varbackendHater=["node.js","php"];varjqueryHater=["jquery"];vartag=newTag({documents: documents});tag.find({watchedTags: fullStack}).exec().documents// Returns all documents matching the specified tags
How to find all documents with .find({ ignoredTags })
varTag=require('../index.js');// Data taken from stackoverflow.comvardocuments=[{title: "How can I remove a specific item from an array?",tags: ["javascript","arrays"]},{title: 'How do I check if an element is hidden in jQuery?',tags: ['javascript','jquery','dom',"visibility"]},{title: 'How do I redirect to another webpage?',tags: ['javascript','jquery','redirect']},{title: 'How do JavaScript closures work?',tags: ['javascript','function','variables','scope','closures']},{title: 'What does “use strict” do in JavaScript, and what is the reasoning behind it?',tags: ['javascript',"syntax","jslint","use-strict"]},{title: 'How to check whether a string contains a substring in JavaScript?',tags: ["javascript","string","substring","string-matching"]},{title: "var functionName = function() {} vs function functionName() {}",tags: ['javascript','function',"syntax","idioms"]},{title: 'How do I remove a property from a JavaScript object?',tags: ["javascript","javascript-objects"]},{title: "Which equals operator (== vs ===) should be used in JavaScript comparisons?",tags: ["javascript","operators","equality","equality-operator","identity-operator"]},{title: "How do I return the response from an asynchronous call?",tags: ["javascript","jquery","ajax","asynchronous"]},{title: "Why does HTML think “chucknorris” is a color?",tags: ["html","browser","background-color"]},{title: "How do I check whether a checkbox is checked in jQuery?",tags: ["javascript","jquery","html","checkbox"]},{title: "How to horizontally center a <div>",tags: ["html","css","alignment","centering"]}];// Followed tagsvarnoobie=["html","css"];varfullStack=["html","css","javascript","node.js","mongoose"];varjqueryFan=["jquery"];// Ignored TagsvarfrontendHater=["html","css"];varbackendHater=["node.js","php"];varjqueryHater=["jquery"];vartag=newTag({documents: documents});tag.find({ignoredTags: jqueryHater}).exec().documents// Returns all documents that doesn't have jquery tag in it.