meteor-job-collection icon indicating copy to clipboard operation
meteor-job-collection copied to clipboard

Cannot set _private data

Open shaiamir opened this issue 8 years ago • 1 comments

I am trying to use the _private option of the job but get Match error: Error: Match error: Unknown key in field _private at exports.check (packages/check.js:57:15) at JobCollectionBase._DDPMethod_jobSave (packages/vsivsi_job-collection/src/shared.coffee:782:5) ...

When calling job.save(). How should _private be used?

shaiamir avatar Dec 22 '16 15:12 shaiamir

Hi, the job you .save() can't have _private data. In your server code, you can update() the saved job to add or modify _private data however you would like, and it will not be passed on to workers.

An alternate mechanism is to define a .scrub() function on the server-side jobCollection object that is passed a job document and returns that document with any private attributes removed. This removes the restriction that such data be under _private.

In either case, the information must be added on the server-side by separate calls to jc.update().

Hope that helps.

vsivsi avatar Dec 22 '16 23:12 vsivsi