Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.62k stars 600 forks source link

Observer with pagination not working #1741

Closed nirajsinghapr9 closed 6 months ago

nirajsinghapr9 commented 9 months ago

I have a query which has pagination, the query works fine and observes changes in database, but when i add pagination, it doesnot observe changes in entire data. const conversations: Collection = database.collections.get( TableName.CONVERSATION, );

export const observeConversation = ( offset = 1, searchText: string, status: string, limit = 50, ) => { console.log('offset ====> ', offset, (offset - 1) limit, offset limit); const statusQuery = status === 'closed' ? Q.eq('closed') : Q.oneOf(['open', 'assigned', 'unassigned']);

return conversations .query( Q.where('status', statusQuery), Q.or( Q.where('customer_name', Q.like(%${searchText}%)), Q.where('customer_contact', Q.like(%${searchText}%)), ), Q.sortBy('modified', Q.desc), // Q.skip((offset - 1) limit), // Q.take(offset limit), ) .observeWithColumns(['modified']); }; example if offset is 1 and limit is 50 it observers all 50 record, but if page is 2 and limit in 50 , it doesnot observe changes in previous data