[FEATURE REQUEST] Auto increment option for selected fields

I find that currently MongoDB is missing an ‘auto-increment’ procedure which as such fails to auto-increment values on a particular field, based on previous inserts.

Say for example, I have the following documents, and before that I have created the collection with these params:

{$autoIncrement: ‘$type’, value: 10, start: 10} (imaginary stage)

{_id: 1,
type: 10},
{_id:2,
type: 20},
{_id:3,
type: 30}

which means that on the next insertion of a document, {_id: 4}, a ‘type’ field would be automatically inserted with the value incremented according to the previously inserted document, i.e. {_id: 4, type:40}

Value of type cannot be set for auto incrementing documents. For an insert of a document, {_id: 8, type: 90} an error is thrown. On a deletion, all the subsequent documents would have their “type” values reduced accordingly.

For example - if we do a deleteOne({_id:2}), the subsequent document structure changes to -

{_id: 1,
type: 10},
{_id:3,
type: 20},
{_id:4,
type: 30}

Maybe this seems unnecessary but at times, one simply wants an auto-incrementing _id value and not something with a timestamp and so on - and instead of running and storing the calculations on the server’s end, the database could do so itself(not to mention the additional call to database, fetching the last increment value per insertion).

However, this would be particularly helpful for those use cases, where a single node is being used and mostly insertion of new data takes place.