Check if searching for an id

This commit is contained in:
Rob 2016-09-12 18:03:39 -07:00
parent 61bf5824ac
commit 6e2e3d5cb7

View file

@ -718,8 +718,13 @@ UserHandler = class UserHandler extends Handler
host: config.sphinxServer
port: 9306
connection.connect()
q = req.body.search;
mysqlq = "SELECT *, WEIGHT() as skey FROM user WHERE MATCH(?);"
q = req.body.search
if isID q
mysqlq = "SELECT *, WEIGHT() as skey FROM user WHERE mongoid = ? LIMIT 100;"
else
mysqlq = "SELECT *, WEIGHT() as skey FROM user WHERE MATCH(?) LIMIT 100;"
connection.query mysqlq, [q], (err, rows, fields) =>
return @sendDatabaseError res, err if err
ids = rows.map (r) -> r.mongoid