How to use Soft Delete feature: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-using-soft-delete/
Some of the potential benefits of using soft delete:
- When using the Offline data Sync for Mobile Services feature, the client SDK automatically queries for deleted records and removes them from the local database. Without soft delete enabled, you need to write additional code on the backend so that the client SDK knows which records to remove from the local store. Otherwise, the client local store and backend will be inconsistent with regard to these deleted records and the client method
PurgeAsync()
must be called to clear the local store. - Some applications have a business requirement to never physically delete data, or to delete data only after it has been audited. The soft delete feature can be useful in this scenario.
- Soft delete can be used to implement an "undelete" feature, so that data deleted by accident can be recovered. However, soft deleted records take up space in the database, so you should consider creating a scheduled job to periodically hard delete the soft deleted records. For an example of this, see [Using soft delete with the .NET backend] and [Using soft delete with the JavaScript backend]. Your client code should also periodically call
PurgeAsync()
so that these hard deleted records do not remain in the device's local data store.
- When using the Offline data Sync for Mobile Services feature, the client SDK automatically queries for deleted records and removes them from the local database. Without soft delete enabled, you need to write additional code on the backend so that the client SDK knows which records to remove from the local store. Otherwise, the client local store and backend will be inconsistent with regard to these deleted records and the client method
Notes:
Soft Delete only works with tables have id of type of "string", otherwise
1. the records will be permantely deleted on calling the delete method from the Mobile Service Client SDK
2. and you'll see an error like "xxx has an integer id member and therefore can not have any members with the system property attribute 'Deleted' " if you add [Deleted] attribute on your mobile app local model when syncing offline data with mobile services.
3. With a table with soft delete (id is type of string and has __deleted (bit) column) enabled, we tried disable soft delete by deleting the __deleted field, but found the query against the table won't work, after added the __deleted back. the query works again