Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objects with multiple key columns in realm.io

Tags:

realm

I am writing an app using the Realm.io database that will pull data from another, server database. The server database has some tables whose primary keys are composed of more than one field. Right now I can't find a way to specify a multiple column key in realm, since the primaryKey() function only returns a String optional.

This one works: //index override static func primaryKey() ->String? { return "login" }

But what I would need looks like this:

//index
override static func primaryKey() ->[String]?
{
    return ["key_column1","key_column2"]
}

I can't find anything on the docs on how to do this.

like image 433
tutiplain Avatar asked Feb 10 '23 13:02

tutiplain


1 Answers

Supplying multiple properties as the primary key isn't possible in Realm. At the moment, you can only specify one.

Could you potentially use the information in those two columns to create a single unique value that you could use instead?

like image 180
TiM Avatar answered Feb 23 '23 19:02

TiM