             return
         }
 
-        if let feed = withFeed {
-
-            feed.attachments.forEach {
-                realm.delete($0)
-            }
-
-            realm.delete(feed)
-        }
+        withFeed?.cascadeDelete()
 
         if let conversation = conversation {
             realm.delete(conversation)


                if let feed = conversation.withGroup?.withFeed {

                    for attachment in feed.attachments {
                        realm.delete(attachment)
                    }

                    realm.delete(feed)
                }

                let groupID = group.groupID

    dynamic var skill: UserSkill?

    dynamic var group: Group?

    // 级联删除关联的数据对象

    func cascadeDelete() {

        guard let realm = realm else {
            return
        }

        attachments.forEach {
            realm.delete($0)
        }

        realm.delete(self)
    }
}


