Created
April 1, 2015 17:34
-
-
Save EcZachly/c002b0405facacf4715c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get '/Cards/adv/search', (req, res) -> | |
console.log(req.query) | |
colors1 = req.query.colors | |
if(colors1 == undefined) | |
colors1 = ["White", "Blue","Black","Green", "Red"] | |
if(colors1.length == 0) | |
colors1 = ["White", "Blue","Black","Green", "Red"] | |
rarity1 = req.query.rares | |
if(rarity1 == undefined) | |
rarity1 = ['Common','Uncommon','Rare', 'Mythic Rare'] | |
if(rarity1.length == 0) | |
rarity1 = ['Common','Uncommon','Rare', 'Mythic Rare'] | |
keyword = req.query.keyword | |
if(keyword != undefined && req.query.subtype != undefined) | |
keyword = keyword.trim() | |
curs = cardCollection.find( | |
{ colors: { $in: colors1 } , rarity:{$in: rarity1}, $text: { $search: keyword}, subtypes: { $elemMatch: { $eq: req.query.subtype} }}).limit(100) | |
else if (req.query.subtype != undefined) | |
curs = cardCollection.find( | |
{ colors: { $in: colors1 } , rarity:{$in: rarity1}, subtypes: { $elemMatch: { $eq: req.query.subtype} }}).limit(100) | |
else if keyword != undefined | |
curs = cardCollection.find( | |
{ colors: { $in: colors1 } , rarity:{$in: rarity1}, $text: { $search: keyword}}).limit(100) | |
else | |
curs = cardCollection.find( | |
{ colors: { $in: colors1 } , rarity:{$in: rarity1}}).limit(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment