longshotlabs/meteor-plans

You must first set the end date to null, then add the new plan

sferoze opened this issue · 0 comments

There is an issue in the order of things done in this method

You must first update endDate, and then setAppPlansObject like so

// Update endDate to be null
  Utility.updateAppPlansObject(options, planName, {
    $unset: {
      'appPlans.list.$.endDate': '',
    },
  });

  Utility.setAppPlansObject(options, modifier);

  return true;

Otherwise, the $addToSet modifier does not work and it adds duplicate plans with exact same parameters in the appPlans.list object

https://github.com/aldeed/meteor-plans/blob/a6b2919600ca65317bdef021ae23350caa1bce60/server/utility.js#L86