I have a list of documents with the following structure:
{
_id : ...,
TotalSeconds: 4021,
InitialTimestamp: 1314547200000
}
Now I want to update all documents TotalSeconds
using InitialTimestamp
. The logic is: TotalSeconds = timenow() - InitialTimestamp
.
What is the best way to do this in mongodb? I'm not sure that this db allows to make such advanced operations using update command. Maybe aggregation framework will help me?