Suppose I have a collection in MongoDB with the following schema:
{
"_id": ObjectID,
"Entries": [
{
"_id": ObjectID,
"Content": string
}
]
}
Now I want to edit the "Content" field of an element from the array "Entries" and then move that element to the first index - zero - so that the array is sorted descending by when the elements were last changed. Can this be accomplished in an 'atomic' query that I can put in one db.collection.update?
If not, should I use say a UNIX timestamp and then just sort by that when querying? Is the performance difference noticable?