Realm Kotlin SDK Sync - Map model class to different name

I’m trying to set up Realm with Device Sync for a new project. I want to add a prefix to my class names for clarity sake (e.g. RlmItem), but I don’t necessarily want that name in the App Services schema. Is there a way that I can manually specify what collection I want the class to sync as?

Hi @Jacob_Rhoda,

You can specify the mapping from an Atlas collection to a Realm object by leveraging the "title" field in your app configuration’s JSON schema. For example, given the class name RlmItem, you can define a schema for the Atlas collection that you want to sync RlmItem to with "title": "RlmItem". Please see the docs for more information – there’s also an example at the bottom of the page to illustrate this.

Let me know if that works,
Jonathan

Hi Jonathan,

That is helpful and I am able to do so… However I was hoping that I could do it on the client side instead of on the Atlas side. That way different apps could name the internal class whatever they want. Is that possible?

Thanks,
Jacob

Jacob,
I believe only some SDKs support this, while others use the class name as a direct mapping to table name (which as Jonathan notes can be configured by the "title" field). What Realm SDK/platform are you using?

@Jacob_Rhoda: Thanks for asking this question.

Sadly, Kotlin SDK doesn’t support this feature as of now but is under our radar.

But, do upvote this issue on Github as it helps us to understand developer needs and balance priorities accordingly.

Looks like this works now with the @PersistedName annotation. Thanks for getting this in so quick!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.