I have an application with react/node.js and firebase db.
Application is a page form where non-logged in user[customer] ( with session Id cookie) fills his details for buying a product (each product is assigned with a seller).
There are registered users, sellers, with a dashboard where they can see / edit that forms (customer's or product details).
I want to make it real-time but of course there is always the problem of double update an input by both seller and non-logged user.
How can I prevent that? Should I add a flag on the session in the db with a timestamp and currentEditor so I should not allow the other person to edit but only to view the real-time changes? (And if the flag's timestamp isn't updated it would allow the other user to take control after a certain time).
Also If I want to log the changes that have been done ( for example seller changed address number on xxx date) should I create a separate database and log something like Session Id, user, data name, data value, date)?
Is my plan correct or is there a better solution?