I’ve tried for the whole day but I cannot get an entry in the jobs collection I created. Here’s the code I’ve added specifically for the package, maybe I’m overlooking something (must be as no one else has such a problem).
This is jobs.js in the collections folder:
if (Meteor.isServer) {
Jobs = new JobCollection('jobs');
Meteor.startup(function () {
console.log("JobServer started: " + Jobs.startJobServer());
return;
});
};
The server report true so is running. The following code is in a separate file and is copied directly from the documentation of the vsivsi:job-collection package:
var job = new Job(Jobs, 'sendEmail', // type of job
// Job data that you define, including anything the job
// needs to complete. May contain links to files, etc...
{
address: 'bozo@clowns.com',
subject: 'Critical rainbow hair shortage',
message: 'LOL; JK, KThxBye.'
}
);
// Set some properties of the job and then submit it
job.priority('normal')
.retry({ retries: 5,
wait: 15*60*1000 }) // 15 minutes between attempts
.delay(60*60*1000) // Wait an hour before first try
.save(); // Commit it to the server
// Now that it's saved, this job will appear as a document
// in the myJobs Collection, and will reactively update as
// its status changes, etc.
console.log ("Job inserted: " + job._id);
Console:
Job inserted: undefined
If I change the last line (console.log) to this:
console.log ("Job inserted: " + JSON.stringify(job));
then console is giving me the following error message:
TypeError: Converting circular structure to JSON
Which is strange as it’s for sure not a circular structure (see above). Like I said I copied the code directly from the documentation 1:1, so I don’t understand why it’s not working (only difference is that I named my job collection differently and left out the .allow and Meteor.publish part.
I’ve also checked the MongoDB directly via console and it doesn’t return any document:
db.jobs.find()
Any help is highly appreciated, I’m ready to throw the towel and give up on this package but it must be something simple that I overlooked. Thanks!