My question relates to http://jira.mongodb.org/browse/SERVER-991. I want a nested variety of a set size storing latest XX occasions associated with current document.

How do i implement client-side this feature? I figured of maintaining a rely on array size, something similar to:

  1. Choose count area from element
  2. Push element to embedded array
  3. If count < XX, then corporation_count Else, pop latest element

The disadvantages of the approach:

  • 3 queries for every event push
  • as mongo does not have transactions, the array might have either less or even more elements than permitted(in the same time frame, two clients push or pop elements) - but this does not bother me greatly

Would you discuss how this may be implemented?

You are able to preinitialize arrays with nulls and eliminate size inspections. Just pop and push. By doing this additionally you avoid size growth and document relocations. The consumer code will need to handle null-ended arrays correctly.