Skip to content

Instantly share code, notes, and snippets.

@taterbase
Forked from EcZachly/gist:c002b0405facacf4715c
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taterbase/fbe6524945002d7019ee to your computer and use it in GitHub Desktop.
Save taterbase/fbe6524945002d7019ee to your computer and use it in GitHub Desktop.
app.get '/Cards/adv/search', (req, res) ->
console.log(req.query)
colors1 = req.query.colors || []
if(colors1.length == 0)
colors1 = ["White", "Blue","Black","Green", "Red"]
rarity1 = req.query.rares || []
if(rarity1.length == 0)
rarity1 = ['Common','Uncommon','Rare', 'Mythic Rare']
keyword = req.query.keyword?.trim()
subtype = req.query.subtype
query = {colors: {$in: colors1}, rarity: {$in: rarity1}}
if (keyword?)
query.$text = {$search: keyword}
if (subtype?)
query.subtypes = { $elemMatch: { $eq: req.query.subtype} }
curs = cardCollection.find(query).limit(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment