My intention is to filter a single line within the results of the previous filter, but returning the same type, so that I can perform a third filter. Here's my attempt:
func salvarDadosAluno(_codPessoa: String, _codCurso: String){
let realm = try! Realm()
let aluno = realm.objects(Alunos.self).filter("codPessoa == %@", _codPessoa).first
//Cannot convert value of type 'Alunos' to expected 'Object.type'
let curso = realm.objects(aluno).filter("codCurso == %@", _codCurso).first
print(cursos)
}
Here's my DB:
class Alunos : Object{
dynamic var codPessoa: String = ""
dynamic var raPessoa: String = ""
dynamic var nomePessoa: String = ""
let cursos = List<Cursos>()
}
class Cursos : Object{
dynamic var codCurso: String = ""
dynamic var desCurso: String = ""
let disciplinas = List<Disciplinas>()
}
And with the result of these searches, I want to insert more disciplines for this student, in this filtered course, like this:
try! realm.write {
curso?.disciplinas.append(curso)
}
How to proceed? Thanks any help