Can this function be optimized for efficiency and readability? I'm not a fan of the repetitive if/else structure, especially considering that it's only setting 'status.edited': false
when method equals 'reset'. Otherwise, it stays unmodified.
function optimizeUpdate(id, method) {
var timestamp = new Date().getTime();
Collection.update(
{ _id: id },
{
$set: { 'status.version': timestamp },
$unset: { 'status.editing': '' }
}
);
if (method === 'reset') {
Collection.update(
{ _id: id },
{
$set: { 'status.edited': false }
}
);
}
}