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

How to find a specific job so that we can change the delay? #236

Open
suryaiiit opened this issue May 29, 2017 · 1 comment
Open

How to find a specific job so that we can change the delay? #236

suryaiiit opened this issue May 29, 2017 · 1 comment
Labels

Comments

@suryaiiit
Copy link

suryaiiit commented May 29, 2017

Thanks for this wonderful package.

I've groups which has 'n' users. There can be multiple groups.. now for each Group I'm creating a JobQueue with a dynamic delay for every run, lets call this frequency.

const GroupJobs = JobCollection('groups');

job = new Job(GroupJobs, 'jobGroup', data);

GroupsJobs.processJobs('jobGroup', ...);

Everything works fine. Now I need to change the frequency of a specific (end-user defined) ... how can I do that?
#157 - this tells me how to do, but how do I get the Job object??

@vsivsi
Copy link
Owner

vsivsi commented May 29, 2017

Hi, a JobCollection is backed by a regular Meteor collection. So you can do a jc.find() query and return one or more job documents of interest. Then there are a couple of ways to turn those into Job objects. One is to individually call new Job(jc, doc) on each one. The other way is to just return an _id or array of _id values, and then either use jc.getJob() or jc.getJobs() to return job documents.

A more convenient approach is to define a transform for the job collection so finds alway return job objects. See for example: https://github.com/vsivsi/meteor-job-collection-playground/blob/master/play.coffee#L9

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

No branches or pull requests

2 participants