No, MongoDB is not inherently an in-memory database, but it can be configured to run as one. MongoDB is a NoSQL, document-oriented database that stores its data on the disk, which allows it to handle large datasets that would not fit into memory.
However, MongoDB does support an in-memory storage engine as part of the MongoDB Enterprise Advanced subscription. This can provide lower latency and high throughput operations for specific use cases but doesn't offer the same persistence guarantees as the default storage engine, WiredTiger.
Here's how you would start a MongoDB server with the in-memory storage engine:
Note that this will only affect data written after the server has started with this configuration. Existing data won't be moved to in-memory storage automatically.
Remember, though, that using MongoDB or any other database as an in-memory database entails trade-offs. While you get faster access times because everything is held in RAM (Random Access Memory), you also face potential data loss if your system crashes or turns off, because RAM is volatile storage. You'll also be limited by the amount of available RAM when storing data.
Hence, it's important to consider your application's specific needs and circumstances before choosing to use an in-memory database or switching storage engines in MongoDB.