I have an entity in my application called Assign which I persist in a MongoDB database.
A kind of assignment history is stored in this entity. That collection has documents that differ slightly in some cases, but the idea is to have a Doubly Linked List (assignments are passed from one person to another), so in all documents there are two fields:
-next (id of the next assignment)
-preview (id of the previous assignment)
This is an example of the document:
{
"id": objectID,
"assignee": objectID of the Assignor Role,
"assigner": objectID of the assignee (lawyer)
"process": objectID of the process,
"next": objectID of the next assignment,
"preview": objectId of the previous assignment,
"assigneAt": time
}
Suppose I have an assignment that has gone through 5 different people. Now suppose I have the id of assignment #3, the idea is to be able to get the previous and next documents (i.e. 1, 2, 4, 5). How can I query this efficiently? Am I in the right direction?