{"action":"created","issue":{"url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/171","repository_url":"https://api.github.com/repos/vsivsi/meteor-job-collection","labels_url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/171/comments","events_url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/171/events","html_url":"https://github.com/vsivsi/meteor-job-collection/issues/171","id":147119177,"number":171,"title":".depends([job]) gives Exception while invoking method 'Play' Error: Each provided object must be a saved Job instance (with an _id)","user":{"login":"ericvrp","id":4216292,"avatar_url":"https://avatars.githubusercontent.com/u/4216292?v=3","gravatar_id":"","url":"https://api.github.com/users/ericvrp","html_url":"https://github.com/ericvrp","followers_url":"https://api.github.com/users/ericvrp/followers","following_url":"https://api.github.com/users/ericvrp/following{/other_user}","gists_url":"https://api.github.com/users/ericvrp/gists{/gist_id}","starred_url":"https://api.github.com/users/ericvrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericvrp/subscriptions","organizations_url":"https://api.github.com/users/ericvrp/orgs","repos_url":"https://api.github.com/users/ericvrp/repos","events_url":"https://api.github.com/users/ericvrp/events{/privacy}","received_events_url":"https://api.github.com/users/ericvrp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vsivsi/meteor-job-collection/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-04-09T10:56:12Z","updated_at":"2016-04-29T23:33:01Z","closed_at":null,"body":"Version 1.3.0 gives the following error when I try to use depends:\r\n\r\n> Exception while invoking method 'Play' Error: Each provided object must be a saved Job instance (with an _id)\r\n> I20160409-12:21:17.624(2)?     at Job.depends (packages/vsivsi_job-collection/job/src/job_class.coffee:607:23)\r\n\r\nWhith the following code.\r\n\r\n```\r\n    var searchJob = new Job(myJobs, 'SearchTest', {\r\n      time  : DEFAULT_SEARCH_TIME,\r\n      play  : false,\r\n      gameId: gameId,\r\n      state : GameState(gameId)\r\n    }).save();\r\n\r\n    var playMoveJob = new Job(myJobs, 'PlayMoveTest', {\r\n     searchJobRef: searchJob.data\r\n    }).depends([searchJob]).save();\r\n```\r\n\r\nTo me the above code looks alright. Any tips?\r\n\r\nP.S. Instead of adding a dependent job to each 'SearchTest' job I would prefer to be able to add a job that depends on jobType (in addition to dependancy on a job)."},"comment":{"url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/comments/215907542","html_url":"https://github.com/vsivsi/meteor-job-collection/issues/171#issuecomment-215907542","issue_url":"https://api.github.com/repos/vsivsi/meteor-job-collection/issues/171","id":215907542,"user":{"login":"vsivsi","id":428642,"avatar_url":"https://avatars.githubusercontent.com/u/428642?v=3","gravatar_id":"","url":"https://api.github.com/users/vsivsi","html_url":"https://github.com/vsivsi","followers_url":"https://api.github.com/users/vsivsi/followers","following_url":"https://api.github.com/users/vsivsi/following{/other_user}","gists_url":"https://api.github.com/users/vsivsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vsivsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsivsi/subscriptions","organizations_url":"https://api.github.com/users/vsivsi/orgs","repos_url":"https://api.github.com/users/vsivsi/repos","events_url":"https://api.github.com/users/vsivsi/events{/privacy}","received_events_url":"https://api.github.com/users/vsivsi/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T23:33:01Z","updated_at":"2016-04-29T23:33:01Z","body":"Hi, I think you misunderstand. You can use `async.series` to manage the callback pyramid when creating and saving your jobs. Even creating the dependent jobs is a series of async operations... \r\n\r\n```js\r\nasync.series([\r\n   function (cb) {  enrichCurrencyJob.save(cb); },\r\n   function (cb) {  enrichRegionJob.save(cb); },\r\n   function (cb) {  \r\n     enrichRightIDJob.depends( [enrichRegionJob] );\r\n     enrichRightIDJob.save(cb);\r\n   },\r\n   function (cb) {\r\n      enrichTaxJob.depends( [enrichRightIDJob] );\r\n      enrichTaxJob.save(cb);\r\n   }\r\n  ], function (err, results) {\r\n   if (err) {\r\n      // handle it\r\n   } else { \r\n     // do something with results\r\n   }\r\n});\r\n```\r\n"}}