How to filter a RealmList of primitives?



I have the following data model:

class Item: Object {
    @objc dynamic var title: String = ""
    let dueDates = List<Date>()
    var parentCategories = LinkingObjects(fromType: Category.self, property: "items")

I’m trying to filter all Item objects in the database with first Date element of their dueDate array being smaller than today’s date. I’ve tried the following but it won’t work:

realm.objects(Item.self).filter("dueDates[FIRST] < %@", today)

I’d appreciate any insight.


Filtering on a list of primitives is not yet supported, you can check for updates here. Until it is implemented, the usual workaround is to wrap your primitive up in an object and filter based on that.


Thanks for the quick reply.