Как мне сделать запрос PUT с JOIN в Thinky?

Как бы я обработал запрос PUT, где я хочу обновить объект, а затем выполнить соединение для предоставленных идентификаторов тегов?

У меня есть это до сих пор:

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 ответов

Другие вопросы по тегам