Im using a node.JS server for a test project im working on that involves a user connecting to the site via an app on their phone, and based on the URL used, will add that data to a doccument for access at a later time (not particualrly important as the accessing data half is done routinely by a single process). but the writing of data from multiple sources worries me in that, if two users were to connect at the same time, (for the sake of discussion, we'll say the exact same tick). what would happen to the file? would there be data corruption/loss? and if so, what would be the best way of preventing it/circumventing the situation (i.e. set one process to wait for the other). since the data will be added at specific locations in the document based on information in the data, im worried that there could be some overwriting/loss of data.
ultimately the question im asking is, if two users try and edit the same document at the same time, what happens and how can i prevent it?
P.S. i can't test this myself as i've not got the best setup for this but it can most assuredly happen regardless of me not being able to reproduce it.
EDIT: on top of all this, how could i prevent the automatic process from blocking the user input should they try and add data while data is being read?
EDIT 2: the file is stored as a single text document in the ./routes directory using the default Express setup.
PREEMPTIVE EDIT: (lol). everything is running on windows 8 64bit, if that makes a difference, which i imagine it could.