Skip to content

Instantly share code, notes, and snippets.

@elimisteve
Forked from BerkeleyTrue/inefficient-save.js
Last active February 19, 2016 02:58
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 elimisteve/0c0547ef17714d6c7c13 to your computer and use it in GitHub Desktop.
Save elimisteve/0c0547ef17714d6c7c13 to your computer and use it in GitHub Desktop.
function completedChallenge(req, res, next) {
const { user, body } = req;
// mutates user object
const { alreadyCompleted } = updateUserProgress(user, body);
// sends entire user object to database
return saveUser(req.user)
.subscribe(
() => {},
next,
function() {
return res.json({
points: user.progressTimestamps.length,
alreadyCompleted
});
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment