领域内对象的谓词谓词

时间:2018-04-26 12:36:50

标签: swift realm nspredicate

我有以下Realm对象

class Patient: Object {

    @objc dynamic var name: String?
    let list = List<RString>()
}

class RString: Object {

    @objc dynamic var stringValue: String?

}

我需要使用Patient

过滤列表中RString个组件的stringValue = "test"个对象

这样的事情可能吗?

patients = realm?.objects(Patient.self).filter("name = 'name1' AND @% IN list", RString(stringValue: 'test'))

1 个答案:

答案 0 :(得分:2)

您需要使用SUBQUERY才能访问ListNSPredicate元素的属性。 SUBQUERY会为truePatient个属性至少包含listRString元素的stringValue元素String评估patients = realm?.objects(Patient.self).filter("name = %@ AND SUBQUERY(list,$element,$element.stringValue == %@).@count>0", "name1", "test") const simpleParser = require('mailparser').simpleParser; simpleParser(data.Body, (err, mail)=>{ if(err){ console.log(err) callback(null, null); }else{ console.log(mail) console.log(mail.attachments[0]) console.log(mail.attachments[0].content) console.log(mail.attachments[0].content.toString('ascii')) callback(null, null); } }) }。

set "KERAS_BACKEND=tensorflow"