question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to query for all changed records including deleted status

See original GitHub issue

I would like to have a counter to know how many items we need to sync to the backend? And i would like to use the enhance options with withObservables like so

const uploadButtonObservable = withObservables<
  UploadButtonPropsIn,
  UploadButtonPropsOut
>([], () => {
  const collection = database.collections.get(tableName);
  return {
    changedCount: collection
      .query(Q.where('_status', Q.notEq('synced')))
      .observeCount(),
  };
});

The problem is that by default the query is extend to exclude _status = ‘deleted’

So How should I tackle this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
radexcommented, May 5, 2021

you can use https://github.com/Nozbe/WatermelonDB/blob/master/src/Database/index.js#L178 to get a signal whenever there’s a change in the DB, upon which you can refetch the value

0reactions
ruben4mobilecommented, May 6, 2021

If there was a way to get the data without this risk I would use it. Problem is that there are possibly multiple projects to sync separately explaining the need for the where clause. I could possibly start a new database per project and drop some raw queries, but not all

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find Modified/New/Deleted Records Between Two Tables
-- DELETED SELECT B.*, 'DELETED' AS 'CHANGE_TYPE' FROM TableB B LEFT JOIN TableA A ...
Read more >
Query Deleted Records in Salesforce: 3 Easy Methods - Learn
To access all the records irrespective of their deletion status, Salesforce requires one to use the QUERY ALL construct.
Read more >
How to track the history of data changes using SQL Server ...
In this blog post, you are going to see how to track the history of data changes using SQL Server 2016 System-Versioned Temporal...
Read more >
SCCM Audit Status Messages Track Who Deleted Modified ...
Launch the SCCM console and navigate via \Monitoring\Overview\System Status\Status Message Queries. Make sure you filter the status message ...
Read more >
Create and run a delete query - Microsoft Support
The DELETE statement is used to delete records in a table. See how to create and use a delete query in Access desktop...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found