mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Limiting how many results try to get fetched on admin DB searches like /db/user so that we don't blow up the DB.
This commit is contained in:
parent
f2a5c4bc5a
commit
880d22ed50
1 changed files with 3 additions and 0 deletions
|
@ -187,14 +187,17 @@ module.exports = class Handler
|
|||
|
||||
# Conditions are chained query functions, for example: query.find().limit(20).sort('-dateCreated')
|
||||
conditions = JSON.parse(req.query.conditions || '[]')
|
||||
hasLimit = false
|
||||
try
|
||||
for condition in conditions
|
||||
name = condition[0]
|
||||
f = query[name]
|
||||
args = condition[1..]
|
||||
query = query[name](args...)
|
||||
hasLimit ||= f is 'limit'
|
||||
catch e
|
||||
return @sendError(res, 422, 'Badly formed conditions.')
|
||||
query.limit(2000) unless hasLimit
|
||||
|
||||
query.exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
|
|
Loading…
Reference in a new issue