How would I prevent dupe?

So I made trade simulator game, and there’s catalog like in roblox.
When people buy item at the same time, serial gets duped.
How would I prevent that?
Btw I am using mongoDB to store item data and current stock

Thanks