async function updateActivityStatus(
  activity,
  status = false,
  message = false,
) {
  // Strict check because we want to allow 0 or empty string
  // but don't want to delete existing data
  const forUpdate = {};
  if (message !== false) {
    forUpdate.errorMsg = message;
  }
  if (status !== false) {
    forUpdate.status = status;
  }

  let success = false;
  try {
    if (activity instanceof QueueActivity) {
      success = await activity.updateOne(forUpdate);
    } else {
      success = await QueueActivity.findOneAndUpdate(
        { activityId: activity },
        forUpdate,
        { runValidators: true },
      );
    }
    return !!success;
  } catch (err) {
    return false;
  }
}
/**
 * Keep an activity in the DB but change its status property
 *
 * @param {QueueActivity|Integer} activity QueueActivity document or ID
 * @param {String} status Status to apply
 * @param {String} message Detail or error info
 * @returns {Bool} Success or failure
 */
Keep an activity in the DB but change its status property
@param {QueueActivity|Integer} activity QueueActivity document or ID
@param {String} status Status to apply
@param {String} message Detail or error info
@returns {Bool} Success or failure
Keep an activity in the DB but change its status property @param { QueueActivity|Integer } activity QueueActivity document or ID @param { String } status Status to apply @param { String } message Detail or error info @returns { Bool } Success or failure
async function updateActivityStatus(
  activity,
  status = false,
  message = false,
) {
  const forUpdate = {};
  if (message !== false) {
    forUpdate.errorMsg = message;
  }
  if (status !== false) {
    forUpdate.status = status;
  }
  let success = false;
  try {
    if (activity instanceof QueueActivity) {
      success = await activity.updateOne(forUpdate);
    } else {
      success = await QueueActivity.findOneAndUpdate(
        { activityId: activity },
        forUpdate,
        { runValidators: true },
      );
    }
    return !!success;
  } catch (err) {
    return false;
  }
}
async function updateActivityStatus ( activity , status = false , message = false , ) { const forUpdate = { } ; if ( message !== false ) { forUpdate . errorMsg = message ; } if ( status !== false ) { forUpdate . status = status ; } let success = false ; try { if ( activity instanceof QueueActivity ) { success = await activity . updateOne ( forUpdate ) ; } else { success = await QueueActivity . findOneAndUpdate ( { activityId : activity } , forUpdate , { runValidators : true } , ) ; } return ! ! success ; } catch ( err ) { return false ; } }
Keep an activity in the DB but change its status property
 @param {QueueActivity|Integer} activity QueueActivity document or ID
 @param {String} status Status to apply
 @param {String} message Detail or error info
 @returns {Bool} Success or failure
Keep an activity in the DB but change its status property @param { QueueActivity|Integer } activity QueueActivity document or ID @param { String } status Status to apply @param { String } message Detail or error info @returns { Bool } Success or failure
// Strict check because we want to allow 0 or empty string // but don't want to delete existing data