From 32d6d4b400db2283172ade7fde715c1477583f27 Mon Sep 17 00:00:00 2001 From: Brett Toomey Date: Thu, 23 Mar 2017 16:50:27 +0100 Subject: [PATCH] Fixed softdelete for classes. --- Sources/NodesModel.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/NodesModel.swift b/Sources/NodesModel.swift index 2c3a36d..ab40553 100644 --- a/Sources/NodesModel.swift +++ b/Sources/NodesModel.swift @@ -44,10 +44,16 @@ extension NodesModel { try Self.query().save(&self) } - public mutating func delete() throws { + public func delete() throws { if Self.softDeletable { - deletedAt = Date() - try save() + var temp = self + temp.deletedAt = Date() + + self.willDelete() + + try temp.save() + + self.didDelete() } else { try Self.query().delete(self) }