I need to implement the FIFO logic with MongoDB collection:
- Pop the first document from MongoDB collection.
- Push the document to MongoDB collection and place it as a last document.
The documents in collection do not have any indexes except auto-generated _id (ObjectId).
I wonder, is it possible to findAndRemove the first document from collection and to guarantee that push and pop operations will perform as FIFO stack atomically?
I know that it is possible to do with an array inside document with atomic push and pop operations, but the main problem is that if I will store all my data inside 1 document's array, it's size will exceed 16MB (the maximum allowed size of MongoDB document)
Thanks in advance, Valentin