Skip to content

yamadapc/mongoose-schedule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-schedule

Build Status Dependency Status devDependency Status Analytics


A Kue Job to schedule a method to be called on some mongoose document or model, depending on whether a document id is passed.

.job

Schedules a method to be called on some mongoose document or model, depending on whether a document id is passed at job.data.doc_id.

Example:

var job = {
  data: {
    model: 'Something',
    method: 'remove',
    execution_date: new Date(20, 1, 2014),
    args: [{ _id: some_id }, { active: false }]
  }
};

mongooseSchedule.job(job, function() {});

This will execute the remove method on the Something model with the defined arguments.

Params:

Type Name Description
Object job A kue job.
Function done A callback function.
Object job.data The job's input data.
String job.data.model The model to schedule a static/method on.
String job.data.method The name of the method to schedule.
Date job.data.execution_date When to execute the method.
String [job.data.doc_id] The target document's id. If provided, the
Array [job.data.args] The arguments to pass into the method.

License

Copyright (c) 2014 Pedro Yamada. Licensed under the MIT license.

About

Safely schedule mongoose methods with kue jobs and cron.

Resources

License

Stars

Watchers

Forks

Packages

No packages published