删除自定义发送给客户端的结果后循环back



在我的回带式应用程序中,我必须自定义发送给客户端的删除结果。

xxxxx.observe('before delete', function(ctx, next) {
      xxxxx.find({
          where: {
            id: ctx.where.id
          }
        }, function (err, transaction) {
            if(yyyy.length > 0){
                var id = yyyy[0]['id'];
                pgclient.query("delete from qqq where kkkk = '"+id+"' ", function(err, dbRes){
                  if(err){
                    next(err);
                  } else{
                    next();----------------> here i have to customize the result
                  }
                });
            } else {
                next({"message":" for the given id"});
            }
        });
    });

现在发送给客户的结果是:

{
  "count": 1
}

,但我需要将其修改为:

{"message":"Deleted Successfully"}.

我对此尝试了很多,但没有结果。请分享您的想法。

你不能。这是操作挂钩,next回调只是为了确定成功/操作失败。

用于自定义消息,您应该在远程方法或远程挂钩中进行

最新更新