No partition fields specified in WildAid O-FISH example

In the latest WildAid O-FISH app example, I see that @Andrew_Morgan has specified that we will be using agency as the partition key and I can see that in the Atlas document from the post.

{
   "_id" : ObjectId("6059c9859a545bbceeb9e881"),
   "agency" : "Ecuadorian Galapagos", // This is the partition key
   "date" : ISODate("2021-03-23T10:57:09.777Z"),
   "status" : "At Sea",
   "user" : {
      "email" : "global-admin@clusterdb.com",
      "name" : {
         "first" : "Global",
         "last" : "Admin"
      }
   }
}

However, what I fail to understand is that the same partition key is not present in the Swift / Kotlin Realm objects.

import RealmSwift

class DutyChange: Object {
   @objc dynamic var _id: ObjectId = ObjectId.generate()
   @objc dynamic var user: User? = User()
   @objc dynamic var date = Date()
   @objc dynamic var status = ""

   override static func primaryKey() -> String? {
      return "_id"
   }
}

Is this done for the brevity of the example or is it not recommended to have the partition key on the client side? Currently, I’ve a RChat like partitioning scheme and I set the values from my client app.

Hi @siddharth_kamaria, it’s a feature of the Realm SDKs and Realm that you don’t need to include the partition key as an attribute in the Realm Objects. Realm Sync will automatically add it to the Atlas document, based on the partition that the mobile app specifies when opening the realm.

2 Likes

That actually makes sense. I should remove my partition keys from object models. Got to learn something new today, thank you @Andrew_Morgan :smiley:

1 Like

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