Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroyAll problem #7

Open
fuzzball1980 opened this issue May 31, 2016 · 0 comments
Open

destroyAll problem #7

fuzzball1980 opened this issue May 31, 2016 · 0 comments

Comments

@fuzzball1980
Copy link

fuzzball1980 commented May 31, 2016

Hi guys!

I have a little problem using the destroyAll on hasManay relations

The problema is that the callback is never called inside the destroyAll method of the mixins.

I have added the parameters options to the method like the definition in the destroyAll of the juggler dao.js and now it works

Model.destroyAll = function softDestroyAll(where, options, cb) {
    if (options === undefined && cb === undefined) {
      if (typeof where === 'function') {
        cb = where;
        where = {};
      }
    } else if (cb === undefined) {
      if (typeof options === 'function') {
        cb = options;
        options = {};
      }
    }

    return Model.updateAll(where, {...scrubbed, [deletedAt]: new Date(), [_isDeleted]: true
      })
      .then(result => (typeof cb === 'function') ? cb(null, result) : result)
      .catch(error => (typeof cb === 'function') ? cb(error) : Promise.reject(error));
  };

The use case where the mixins fail is the following:

User.upsert(new User(user), function(err, instance) {
      if(err) {
        return cb(error);
      }

      instance.roles.destroyAll(function (error) {
       // never enter  here
      });
});

Where RoleMapping model has SeoftDelete enabled.

I'm missing something? or is ti a real bug?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant