I have a node server deployed , It's job is to update the database of the connectivity status of IOT devices
Problem
- Since NodeJS executes asynchronously and is single threaded let's assume I receive the status something like
DisconnectedandConnectedsimultaneously. - Sometimes what happens is that due to NodeJS being asynchronous ,
Connectedgets processed first andDisconnectedgets processed next. - This leaves my database in an inconsistent state.
Result Wanted
- I want to update the database in order at which it happened at source ( i.e According to Timestamp )
So how do i achieve this if NodeJS is single threaded and each request does not share any memory with each other whatsoever ?