From cadb5e452447fb81adc8df95661b8d8bc5667355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 23 Mar 2015 11:48:48 +0100 Subject: [PATCH] Use `ctx.instance` provided by "after delete" hook Use the recently added context property `ctx.instance` to improve the accuracy of the algorithm detecting whether a single or multiple models were deleted. --- lib/persisted-model.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/persisted-model.js b/lib/persisted-model.js index b33a0cb0..90a5c861 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -1362,7 +1362,9 @@ function rectifyOnSave(ctx, next) { } function rectifyOnDelete(ctx, next) { - var id = getIdFromWhereByModelId(ctx.Model, ctx.where); + var id = ctx.instance ? ctx.instance.getId() : + getIdFromWhereByModelId(ctx.Model, ctx.where); + if (id) { ctx.Model.rectifyChange(id, reportErrorAndNext); } else {