In SQL this would be expressed similar to
BEGIN TRANSACTION
DECLARE @nextNumber INT = (SELECT MAX(number) + 1 FROM MyTable WITH UPDLOCK)
INSERT INTO MyTable(name, number) VALUES ('My Name', @nextNumber)
COMMIT TRANSACTION
I cant find any examples of this kind of thing in MongoDB that would not be a two step, non atomic operation. Is this even going to be possible with MongoDb?