How to retrive data through database observer in Swift4?

Can you clarify what you mean by “local DB” ? Are you using something else other than Couchbase Lite as your local DB ?

And this is an example of how you would use database listener

 _db?.addChangeListener({ [weak self](change) in
                guard let `self` = self else {
                    return
                }
                for docId in change.documentIDs   {
                    if let docString = docId as? String {
                        let doc = self._db?.getDocument(docString)
                       
                        print("doc.isDeleted = \(doc?.isDeleted)")
                    }
                }
                
            })