Yes, it is. I’ve always been a fan of uniquing, and it was a bit difficult to let go of it, but this was important for making multithreading work with mutable Document objects. For example, if you have a Database object and two threads concurrently get the document “foo”, you don’t want them to get the same Document object, or all of their individual property changes will step on each other. Instead you want isolation between threads so that each will see only the original state and its own changes. (Of course they will run into conflicts if both save, but that just involves merging two individually-consistent revisions, which is cleaner.)
Yeah, I think that with model objects you really need uniquing, otherwise things get really weird, especially as you follow references between models. For example, let’s say documents “alice” and “bob” both have a property ‘mother’ that refers to the person’s mother
let alice = MyModel(db, “Alice”)
let aliceMom = alice.mother
let bob = MyModel(db, “Bob”)
let bobMom = bob.mother
Let’s say Alice and Bob are siblings. Then I would expect aliceMom and bobMom to refer to the same object, otherwise you can get weird behaviors where you change a property via one reference and don’t see it in the other reference.
Fortunately uniquing is pretty easy to do. In the Obj-C 1.x implementation it’s done with a class called CBLCache.
—Jens