Does CBL do uniquing like CoreData?

15 views
Skip to first unread message

Brendan Duddridge

unread,
Jun 13, 2015, 5:36:00 PM6/13/15
to mobile-c...@googlegroups.com
Hi,

Does CBL properly unique objects it has fetched from the database? That is, if you fetch a to-one child object 'A' by referencing its property from a parent object and then you fetch a to-many array of child objects of the same type, possibly even from a different parent object, and one of them is also object 'A', will object 'A' have the same pointer address in both cases? Or will there be two instances of object 'A' in memory? Both object 'A' would have the same document ID in the database, but I want to make sure that they are actually the same object in memory. If not, then I would need to keep a separate object store cache and every time I fetch from the database, I'd have to check to see if I have an object with a matching document ID already in memory and use that one instead of the one fetched from the database. Which would be a real pain.

Thanks,

Brendan

Jens Alfke

unread,
Jun 13, 2015, 7:28:31 PM6/13/15
to mobile-c...@googlegroups.com
Yes, there’s always at most one CBLDocument instance for a given documentID. Same goes for CBLModels.

—Jens

Brendan Duddridge

unread,
Jun 13, 2015, 8:37:20 PM6/13/15
to mobile-c...@googlegroups.com
Awesome! Thanks!

Brendan
Reply all
Reply to author
Forward
0 new messages