How should I do a PUT request with a JOIN in Thinky?

72 views Asked by At

How would I handle a PUT request where I want to update and object, and then do a join for the provided tag ids?

I have this so far:

ctrl.put = function *(next){
  var id = this.params.id;
  var data = this.request.body;
  var tags = data.tags;

  delete data.tags;
  data.updatedAt = new Date();

  var post = yield Post.get(id).update(data);

  post.tags = tags;

  //how do I update the `Post_Tag` table here with the new tag list?
  //I also want to delete the old tag ids if they are not present in this new list

  var result = yield Post.get(post.id).getJoin({ tags: true });

  this.body = result;

  yield next;
};
0

There are 0 answers