mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -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 are chained query functions, for example: query.find().limit(20).sort('-dateCreated')
|
||||||
conditions = JSON.parse(req.query.conditions || '[]')
|
conditions = JSON.parse(req.query.conditions || '[]')
|
||||||
|
hasLimit = false
|
||||||
try
|
try
|
||||||
for condition in conditions
|
for condition in conditions
|
||||||
name = condition[0]
|
name = condition[0]
|
||||||
f = query[name]
|
f = query[name]
|
||||||
args = condition[1..]
|
args = condition[1..]
|
||||||
query = query[name](args...)
|
query = query[name](args...)
|
||||||
|
hasLimit ||= f is 'limit'
|
||||||
catch e
|
catch e
|
||||||
return @sendError(res, 422, 'Badly formed conditions.')
|
return @sendError(res, 422, 'Badly formed conditions.')
|
||||||
|
query.limit(2000) unless hasLimit
|
||||||
|
|
||||||
query.exec (err, documents) =>
|
query.exec (err, documents) =>
|
||||||
return @sendDatabaseError(res, err) if err
|
return @sendDatabaseError(res, err) if err
|
||||||
|
|
Loading…
Reference in a new issue