Realm (Swift) - Storing Dictionary of type [String: [String]]

326 views Asked by At

I'm trying to store a model in Realm where an object has a swift type of [String: [String]]. I'm attempting to represent this as Map<String, List<String>> however the compiler is complaining Type 'List<String>' does not conform to protocol 'RealmCollectionValue'

My model is below:

import Foundation
import RealmSwift

public class PersistedUser: Object {
    public override init() { }

    @Persisted(primaryKey: true) public var id: UUID?
    @Persisted public var firstName: String = ""
    @Persisted public var lastName: String = ""
    @Persisted public var positions: Map<String, List> = Map<String, List<String>>()
}

Does Realm support this? If so, how does one go about doing it? I've looked at the docs here https://www.mongodb.com/docs/realm/sdk/swift/data-types/collections/ and can't seem to find any mention of support or lack thereof.

0

There are 0 answers