NetTalk Central

Author Topic: PWA/Disconnected app and Deleted records  (Read 5877 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
PWA/Disconnected app and Deleted records
« on: January 14, 2019, 07:46:13 PM »
Bruce,

     In the PWA I'm experimenting with, I have a few deleted records in the local store (IndexedDB) and in the tps table on the server.  I want to leave these in the respective tables, but filter them out in the PWA app.  I assume I'll need a client side filter in JavaScript to accomplish this.  I tried adding both a JavaScript and Clarion filter to the filter tab of the browse, without success.  In looking at the details of the local store fields, I see the DeletedTimeStamp is listed as dts.  So, I tried a JavaScript filter of:  dts > 0; 

This did not work.  Can you provide an example that might work?

     I then looked at the generated code of the browse, and saw two items:  p_web.RemoveDeletedRecords and loc:RemoveDeletedRecords.  I did not see any reference to these in the docs but it seems these might be variables I could use to "filter" the browse and not display the records marked for deletion.  Can you offer an example of how to use either of these? 

     By the way, I noticed the following in the code:

  If p_web.RemoveDeletedRecords
    If loc:FilterWas
      loc:FilterWas = '(' & clip(loc:FilterWas) & ') AND CC:DeletedTimeStamp = 0'
    Else
      loc:FilterWas = 'CC:DeletedTimeStamp = 0'
    end
  End

It seems to me the filter should contain  'CC:DeletedTimeStamp > 0', in order to filter out those deleted records with a deleted time stamp greater than 0.  Is this an error?

Thanks,

Jeff

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnected app and Deleted records
« Reply #1 on: January 15, 2019, 12:05:06 PM »
Bruce,

     In the NT 11.04 docs for Disconnected Desktop Apps, I see a paragraph:

"Purge Deleted Records on Sync
If this is on the the client database will not keep any deleted records after they have been sent to the server. Deleted records typically live on the server for a while (so they can be replicated to other databases) but if this option is on then deleted records are not stored on the client machine."

I cannot find this anywhere.  Is it only for Disconnected Desktop Apps?  This would solve my delete problem, as I only want the deleted records on the server.

Thanks,

Jeff

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnected app and Deleted records
« Reply #2 on: January 15, 2019, 12:29:43 PM »
Ok, made some progress here.  On the Browse, I added a JS filter:

'return record.dts == 0 ? recordOk : recordFiltered'

This filters the deleted records from the browse, but they remain in the local store and in the tps file on the server.  I want to get to the point where they are not in the local store (on the device) but do remain on the server, where I can deal with them as needed.

Jeff

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: PWA/Disconnected app and Deleted records
« Reply #3 on: January 15, 2019, 11:55:31 PM »

There are 2 things in play here;
a) the server _must_ send deleted records to the client - because that's the only way the client will know they are deleted.
(Because of the nature of the sync, they only get sent once - and after some "suitable period of time" they can be purged from the server.

b) The client can then choose to keep, or remove them from the local database.

>> I cannot find this anywhere.  Is it only for Disconnected Desktop Apps?

yes.

>>  I then looked at the generated code of the browse, and saw two items:  p_web.RemoveDeletedRecords and loc:RemoveDeletedRecords.  I did not see any reference to these in the docs but it seems these might be variables I could use to "filter" the browse and not display the records marked for deletion.

Be aware that the browse procedure in your app serves two purposes. It provides the HTML for the browse itself, and in the case of a _web_ request serves up the data to the web app as well. For a disconnected app the data comes from the local store, NOT the server, so there is no filter in play.

>> It seems to me the filter should contain  'CC:DeletedTimeStamp > 0', in order to filter out those deleted records with a deleted time stamp greater than 0.  Is this an error?

Only in the sense that you are misunderstanding how filters work. In Clarion filters filter "in" not "out". So CC:DeletedTimeStamp = 0 means it includes records where CC:DeletedTimeStamp = 0 - ie "only records that have not been deleted" are included.

I think perhaps this issue stems from your browse not being in "file loaded" mode. If in file-loaded mode Deleted records should (by default) be excluded. I believe that to be working, but if not it's something I could dig into further.

cheers
Bruce




jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnected app and Deleted records
« Reply #4 on: January 17, 2019, 06:33:30 AM »
Thanks Bruce, lots of new stuff to learn with regards to JavaScript!

Jeff

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnected app and Deleted records
« Reply #5 on: January 18, 2019, 05:05:49 PM »
Bruce,

     I have made quite a bit of progress today, and I'll detail that in the other thread I have going.  But for this "delete" thread it appears that deleted records are not being excluded from my local browse...even though I am in file-loaded mode.  Could you dig into this further?  I have attached an image, it shows in DevMode there is one record with a dts > 0 that is still showing in the browse (the very first record).

Thanks,

Jeff
« Last Edit: January 18, 2019, 05:17:28 PM by jking »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: PWA/Disconnected app and Deleted records
« Reply #6 on: January 20, 2019, 10:52:14 PM »
perhaps send me the updated app, with some data (server side data) and I can sync the app with the server to see what's going on...

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: PWA/Disconnected app and Deleted records
« Reply #7 on: January 21, 2019, 04:41:25 PM »
Bruce,

I sent the app, dct and tps files via email.

Thanks,

Jeff

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: PWA/Disconnected app and Deleted records
« Reply #8 on: January 22, 2019, 07:18:36 AM »
thanks Jeff, helped me find a small bug - fixed in 11.05