I need to lock entire collection before query.
1. Lock this collection
2. Query this collection
3. Update some fields in this collection
4. Release the lock
I need this because my business is for currency exchange. For example, user A do a search and the search result will reserve for user A and if user B do a search after like 1 second, user B won't get any result.
User A will be given 30 seconds to decide if she likes the result. If 30 seconds is over or user A close the page, business logic will query same collection and remove value from a field so that user B or other user can get same result as user A since user A is not interested in the result returned.
There is no simply way to do this, unfortunately. The only way to handle this would be with complex business logic and adding a field to your existing dataset. Once you add a field (perhaps called lock) just treat it as a boolean and force a wait if the lock is enabled and retry after x seconds.
Sorry this couldn't be something easier to do out of the box.