⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Is there a way to lock a record while editing to avoid crushing data by another user



Michael May Webber
  • profile picture
  • Member

Posted 17 March 2015 - 14:28 PM

I don't know if it is already coded in GROCERY CRUD, but I wonder if there is a lock record on it to avoid been crushed by another user that working on the same render ?  :blink:


Amit Shah
  • profile picture
  • Member

Posted 20 March 2015 - 19:58 PM

technically - no - there is not ...

how you can do it - when you land on the action ..

check if anyone is already editing or not.

if the same is requested for editing - set a flag in the table before allowing the user to edit. (Do store the last edit request time). It needs to have a timeout or it will be locked forever. Let there be a cron running every x minutes to free the record from lock in case of timeout). Also flag the same in the users session that he is editing the record.

 

Post the update (in the callback) - free the record for editing. and free the users session also.

Now in case the user dose not reach the update callback and returns in midway - there is a good option for the system to understand that this user had locked a record .. and hes returned to the scree for some reason - its a good reason to free him up.

 

Hope this works out for you.

 

Happy GCing :)