For example, we have a table like below
car_id, car_name, car_status, engine
100, car1, running, A
200, car2, stop, B
The business logic is engine can not be updated while car_status is running
The most obvious step is
The problem is that someone may change the status to running during the time between step 1 and 2.
How do you to prevent this in RDBMS and mongo?
我认为您只需要保留一种在应用程序中更新car_status的方法,并将该函数作为更新car_status的唯一方法公开(您可以在数据库中创建一个对此表或集合具有写权限的用户,这将强制您必须始终仅使用该user_id来运行此更新操作,当然,这在从应用程序执行时同样适用。)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.