At a certain time interval a IoT device sends data to my backend, I want to keep a document that defines the current state of the device but I also want to see all the other states that the devices has been through.
So I will have State0 - document in my database that contains some information about the device, at State1 I will get some new information that could overwrite the State0 information, but I want to keep track of the changes in the state of the device, so I want to insert a new document that has information merged from State0 and State1 this being the current state of the device.
So my question is: is there a way to easily insert a new document based on information from a previous document? Without finding that document and merging all the fields and after that saving the new document? Does mongo have support for this in any way? Is there another better approach to my problem?
Thanks