> On Aug 7, 2017, at 10:25 AM, Brendan Duddridge <brend...@gmail.com> wrote:
> 
> No worries. I'm fine waiting for CBLModel. I still have to figure out how to 
> sync with Apache CouchDB / Cloudant anyway and I have no idea how to start 
> with that. I really wish you had a compatibility layer or something to help 
> with the transition in that area. Can I pay you to build one?

Oof, this would amount to writing a new replicator for the CouchDB/1.x REST 
protocol, or at least ripping the old replicator out of the CBL 1.x Objective-C 
sourcebase and making it work with 2.0. Either of those would be quite a bit of 
work. At this point, after six years, I’m personally ready to say goodbye to 
that protocol and I don’t really need the extra cash :)

> But not having uniquing is definitely a new twist on things.

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.)

> Is that something you would build-in to the CBLModel implementation or is 
> that left as an exercise for the developer?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mobile-couchbase+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/FBEAAC7A-4831-413F-A22E-3BC893D10DE7%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to