liveBook · Manning

MongoDB

As explained in Quarkus in Action

MongoDB is an open-source document-oriented NoSQL database system that stores data in flexible, JSON-like documents.

MongoDB is a document-oriented NoSQL database that stores application data as JSON-like documents rather than relational rows. In Quarkus, the Panache integration maps Java entities to MongoDB documents while retaining a familiar persistence style. section 7.6

Integrating MongoDB with Panache follows a short application setup:

  • Add the quarkus-mongodb-panache extension and configure the connection string and database. section 7.6.1
  • Define an entity by extending PanacheMongoEntity, or use PanacheMongoEntityBase when declaring a custom identifier. section 7.6.1
  • Use PanacheMongoRepository or PanacheMongoRepositoryBase when applying the repository pattern. section 7.6.1
  • Use Dev Services during development when the production connection property is undefined. section 7.6.1

Persisting rental documents

A Rental entity can store userId, reservationId, dates, and an active flag. A start endpoint creates and persists a rental; an end endpoint finds it by userId and reservationId, updates its state, and returns the document. A listActive method queries active rentals. MongoDB transactions are available from version 4.0 but are not required for this flow. section 7.6.2

Listing 7.26 Adding quarkus-mongodb-panache extension
$ quarkus ext add quarkus-mongodb-panache
Looking for the newly published extensions in registry.quarkus.io
[SUCCESS] ✅  Extension io.quarkus:quarkus-mongodb-panache has been
 installed

Use the extension command as the starting point for enabling MongoDB Panache in a Quarkus service. section 7.6.1

MongoDB uses ObjectId identifiers through PanacheMongoEntity rather than numeric IDs. Services exchanging these entities must account for the identifier becoming a String in serialized responses and client-side models. section 7.6.3

How Quarkus in Action covers it

How deep it goes
Explains extension setup, configuration, entity mapping, queries, persistence, verification, and ObjectId integration, but not database internals.
Examples
Demonstrates a Rental entity, active-rental queries, REST start and end operations, HTTP responses, and mongosh verification.
What it assumes
Assumes Java and Quarkus REST application structure while teaching MongoDB configuration, Panache entities, persistence, and identifier changes.
What you can do after
Build it from scratch with Quarkus Panache, persist JSON-like documents, query them, and verify their stored MongoDB representation.
How it connects
Connects MongoDB with NoSQL databases, Quarkus, Panache, Dev Services, REST, Jackson, and ObjectId identifiers.

Also explained in

Compare how 7 books explain MongoDB →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.