1.1.1 • Published 10 years ago

mongoose-schedule v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

mongoose-schedule

Build Status Dependency
Status devDependency
Status

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:

TypeNameDescription
ObjectjobA kue job.
FunctiondoneA callback function.
Objectjob.dataThe job's input data.
Stringjob.data.modelThe model to schedule a static/method on.
Stringjob.data.methodThe name of the method to schedule.
Datejob.data.execution_dateWhen to execute the method.
Stringjob.data.doc_idThe target document's id. If provided, the
Arrayjob.data.argsThe arguments to pass into the method.

License

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