I am struggling with joining my User and Job Models using Thinky.io.
In the docs, there is an example here of how hasMany works to attach posts to an author. I would like the same set-up for our users: each user would ideally have a job field that saved all the jobs they are interested in. This is how I've set up the User-Job relationship: User.hasMany(Job, 'jobs', 'id', 'userId'). This is as far as I've gotten with my add Job function:
module.exports.addJob = function*(next) {
this.type = 'application/json';
var user = yield User.get("473ade1a-d2df-4618-9a53-ed68fa98f169").run();
const joins = yield User.get(user.id).getJoin().run();
const jobData = yield parse(this);
const job = new Job(jobData);
user.jobs = job;
var userJoined = yield user.saveAll({jobs: true});
This is just setting user.jobs to whatever current job the user clicked on. I tried pushing the new job onto user.jobs, but that did not work either. I can see the information in the console, but this relationship does not get saved to the database as far as I can tell. Has anyone dealt with this issue before? I'm new to StackOverflow, so let me know how I can clarify my question. Thank you!