         
         try self.delete(entries)
     }
-
+    
     
     override open func erase(_ entityId: String) throws {
         guard let entry = readFromRealm(entityId) else {

        }
    }
    

    private func cascadeDelete(_ object: AnyObject?) {
        if let deletable = object as? CascadeDeletionProtocol {
            deletable.objectsToDelete.forEach { child in
                cascadeDelete(child)
            }
        }

        if let realmArray = object as? ListBase {
            for i in 0..<realmArray.count {
                let object = realmArray._rlmArray[UInt(i)]
                cascadeDelete(object)
            }
        }

        if let realmObject = object as? Object {
            self.realm().delete(realmObject)
        }
    }


    private func realm() -> Realm {
        return try! Realm()
    }

    
    private func defaultRealmPathIsEqualToPath(_ path: URL?) -> Bool {
        guard let path = path else {
            return false
        }
        return Realm.Configuration.defaultConfiguration.fileURL == path
    }
    

    private func loadDefaultRealm(configuration: RealmConfiguration) {
        guard let path = self.pathForFileName(configuration.databaseFileName) else {
            fatalError("Cant find path for DB with filename: \(configuration.databaseFileName)" +
                " v.\(configuration.databaseVersion)")
        }
        if defaultRealmPathIsEqualToPath(path) {
            return
        }

        assignDefaultRealmPath(path)
        assignEncryptionKey(configuration.encryptionKey)
        migrateDefaultRealmToCurrentVersion(configuration: configuration)
    }

    
    private func pathForFileName(_ fileName: String) -> URL? {
        let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first as NSString?
        guard let realmPath = documentDirectory?.appendingPathComponent(fileName) else {
            return nil
        }
        return URL(string: realmPath)
    }

    
    private func assignDefaultRealmPath(_ path: URL) {
        var configuration = Realm.Configuration.defaultConfiguration
        configuration.fileURL = path
        Realm.Configuration.defaultConfiguration = configuration
    }
    
    private func assignEncryptionKey(_ key: Data?) {
        var configuration = Realm.Configuration.defaultConfiguration
        configuration.encryptionKey = key
        Realm.Configuration.defaultConfiguration = configuration
    }

    private func migrateDefaultRealmToCurrentVersion(configuration: RealmConfiguration) {
        var config = Realm.Configuration.defaultConfiguration
        config.schemaVersion = configuration.databaseVersion
        config.migrationBlock = configuration.migrationBlock
        Realm.Configuration.defaultConfiguration = config
    }

}

            try realm().commitWrite()
        }
    }
    
    
    override open func read(_ entityId: String) -> Model? {
        guard let entry = readFromRealm(entityId) else {
            return nil
        }
        
        let entity = Model()
        translator.fill(entity, fromEntry: entry)
        
        return entity
    }
    
    
    open override func read() -> [Model] {
        return readFromRealm().map {
            let entity = Model()
