Skip to content

Commit

Permalink
Potentially decrease some traffic to/from DB
Browse files Browse the repository at this point in the history
* Similar to `countTask` but **without** the host CPU/MEM bulk of *async* and related abstraction.
* Returns the cursor count, instead of the document, which can be smaller usually

Post OpenUserJS#1174
  • Loading branch information
Martii committed Oct 18, 2017
1 parent 26f949d commit 5b605f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ exports.exist = function (aReq, aRes) {
return;
}

User.findOne({
User.count({
name: caseInsensitive(username)
}, function (aErr, aUser) {
}, function (aErr, aCount) {
if (aErr) {
aRes.status(400).send();
return;
}

if (!aUser) {
if (aCount === 0) {
aRes.status(404).send();
return;
}
Expand Down

0 comments on commit 5b605f7

Please sign in to comment.