Open chetan51 opened 13 years ago
Currently: it doesn't. This has to be added at some point. I started work on this, but haven't finished it yet.
I worked around this issue by adding an "is_active" flag to my content and syncing that, and only displaying records that are active. I find that's a pretty good DB best practice anyway, so it works well for me.
I have to agree with umbrae, adding an "is_active" flag really works for me, although I would go with a "_isDeleted" like the "_lastChange" field.
Yes I know that's now two 'extra' fields that every synced table has to have, but it makes it obvious very quickly that every interface has to honour this as a way of deleting records.
It may be a bit of bloat, but in theory the 'local' deleted record could be removed once it had been synced up to the central repository. Although if it was kept locally then you would reduce even further the risk of re-allocating keys and ending up with unwanted relationships.
Not sure when it was added, but there is already a flag for deleting entities, it's called '_removed'. The following JSON would result in a delete.
{
"now":1329222505551,
"updates":[
{
"id":"c8340484-c1b7-4bf1-9a8f-a42af6f20f2d",
"_removed":true
}
]
}
I currently use an 'IsActive' field too because the server would have to have a "tombstone" table to know what IDs to flag as deleted for a period of time.
var Tombstone = persistence.define( 'Tombstone',
{
entity:"TEXT",
objectId:"TEXT",
deleteDate:"DATE"
});
For example, if you delete an object on the server's database and try to sync, what would happen?