Chris Shiflett just posted a great summary on how he was able to achieve auto-incrementing identifiers in MongoDB.
We are currently working on an app that uses a number of technologies, including PHP, Python, and MongoDB. Recently, a need arose to use sequential identifiers for users, similar to an auto_increment column in MySQL.
The technique is simple, although some may argue not as elegant as the MySQL implementation. It works by defining a collection of incrementors, which hold an incrementing value for other collections.
Each time a new document is added, you simply findandmodify() your incrementor collection and put the new incremented value into your document to be saved.
While not elegant (compared to MySQL or similar), this approach actually offers much more flexibility in the long run.
via Chris Shiflett.