1

我将如何处理我想要更新和反对的 PUT 请求,然后为提供的标签 ID 进行连接?

到目前为止我有这个:

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;
};
4

0 回答 0