darkterra / mongo-scheduler

Persistent event schedule for node.js using mongo as storage
MIT License
8 stars 8 forks source link

Removing a single event by id is not possible. #4

Closed AlexanderProd closed 5 years ago

AlexanderProd commented 5 years ago

I've been trying to delete a single event by providing an eventName as well as an id to scheduler.remove() but it doesn't remove anything and just results

{
    "n": 0,
    "ok": 1
}

I've used an ID returned by scheduler.list()

Also the usage of collection.remove with mongodb seems to be deprecated but I guess it should work anyways.

I'm using version 1.2.1

darkterra commented 5 years ago

Hey AlexanderProd !

I just tried to delete an event stored in DDB and I have not encountered any problem, my event is deleted correctly, of course the others remained intact.

I grant you, the documentation needs to be reviewed to be more explicit ;)

For the deletion to work on a document specifically, the scheduler.remove () method must be given the name of the event and the id (objectID and not a String as indicated in the documentation) . Ex:

scheduler.remove('my-event', objectId('5a5dfd6c4879489ce958df0c'), null, (err) => {
  if (err) {
    throw err;
  }
});

The pull request that you propose is a good idea :)

darkterra commented 5 years ago

AlexanderProd,

I will deploy this fix in the next version (1.2.3). Can you confirm that this is correct once the downloaded update on your project?

AlexanderProd commented 5 years ago

Yeah the fix is working, I've already tried it on my project in development. Just waiting for the release to use it in production.

darkterra commented 5 years ago

Hey Alexander !

I made a big update! Be careful, it breaks a lot of things, I advise you to watch the new doc to make the necessary adaptations :)