MongoDB Inc. shares soared in the extended session Tuesday after the database company surprised Wall Street with a profitable quarter.