Issue #93 Fix by porting iOS code over.

https://github.com/couchbase/couchbase-lite-java-core/issues/93