Search⌘ K
AI Features

Panache with MongoDB

Explore how to use the Panache MongoDB extension in Quarkus to handle database operations. Learn both the active record and repository patterns to create, persist, list, and delete entities effectively within your applications.

The Quarkus team provides an extension that simplifies the usage of a MongoDB database called mongodb-panache, which we can use to take advantage of the Panache helpers with a MongoDB database.

Adding the dependencies

To use the Panache MongoDB extension, we need to add it as a dependency using the commands below depending on your build tool.

Shell
# Using Quarkus CLI
quarkus extension add 'mongodb-panache'
# Using Maven
./mvnw quarkus:add-extension -Dextensions='mongodb-panache'
# Using Gradle
./gradlew addExtension --extensions='mongodb-panache'

Using Panache

When using the Quarkus Panache extension, we can pick one of the two available patterns: the active record pattern or the repository pattern.

Active record pattern

The active record pattern relies on the created entities to make different kinds of operations. We’ll need ...