Query Listener working weird in Couchbase Mobile Lite iOS Swift

Hi,
I have following query builder, When i run this query, i am getting 5 documents. So i changed one document out of 5 documetns. But in LiveQuery Change listener i am getting 5 records again instead of only one records, which are changed recently.

So how to get only changed records from the query in change listener?

  •                                    (OR)
    

is Querybuilder reexecture, if any values changed on query?

 livequeryForCompleted = QueryBuilder
                .select(SelectResult.all())
                .from(DataSource.database(CouchbaseSingleton.shared.database!))
                .where(Expression.property( CBConstants.kDocumentType).equalTo(Expression.string(documenttype))
                    .and(Expression.property(CBConstants.kID).equalTo(Expression.string(id)))
                    .and(Expression.property(CBConstants.kdpIsProcessed).equalTo(Expression.boolean(true))))
            if let query = livequeryForCompleted{
                do {
                    let result = try query.execute()
                    let resullist : [Result] = result.allResults()
                    Print.print("isProgress true count \(resullist.count)")
                }
                catch{
                    
                }
                completedListenerToken = query.addChangeListener { (change) in
                    for (i,output) in change.results!.enumerated() {
                        print("\(i+1). isProgress true Docs is \(output.toDictionary())")
                    }
                }
                
            }

That’s how it’s supposed to work. It gives you the current results. If you want to figure out which changed, you’d need to store a copy of the old results and compare with the new ones.

Thanks for clarifying.

@jens Live Query working very weird. Sometimes it is returning 4 documents and sometimes 2 records. no one is updating or editing server docs. Do you know what is the issue?