I have an "orders" collection, where each document contains a "merchantId" and a "customerId". I want a document to be partioned and available in multiple realms e.g. customer="customer1" and merchant="merchant1" realm. I don't know if it is even possible. If yes, please help.
Asked
Active
Viewed 259 times
0
-
Welcome to SO. The question is a bit unclear. A collection (a Swift Class) can contain documents and each document has a partition property. You can access a collection through a number of Realm Apps but I think what's unclear is when you say 'available in multiple realms' - A Realm is a single 'container' and the data in each container would be different (unless you're denormalizing your data, but that's a different thing). Can you clarify? Perhaps include some objects and explain your use case? – Jay Oct 30 '20 at 16:18
-
Thanks Jay, the order collection contains doc {_id:"1234", title:"test", merchantId:"merchant1", customerId:"customer1", items:["items1", "items2"]}. I want this document to be available in realm for "merchant=merchant1" and "customer=customer1". – Surender Nandal Nov 01 '20 at 14:32
-
Please add structures, code and additional clarification *in the question* as they are hard to read in comments and so others don't have to scan through comments to understand the question. Assuming you want to use sync, Realm objects also require a [partition key](https://docs.mongodb.com/realm/sync/partitioning/#partition-keys) property so take a moment and take a look at that documentation. – Jay Nov 01 '20 at 15:56
1 Answers
0
A single document may not appear in multiple partitions as of Nov 2020. From the documentation
Each unique partition value, or value of a partition key, maps to a different realm. Documents that share the same partition value belong to the same realm.

Nikola Irinchev
- 1,911
- 1
- 13
- 17