Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB documentation improvements #8515

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/src/main/asciidoc/mongodb-panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,17 @@ TIP: Using `@BsonProperty` is not needed to define custom column mappings, as th

TIP: You can have your projection class extends from another class. In this case, the parent class also needs to have use `@ProjectionFor` annotation.

== Query debugging

As MongoDB with Panache allows writing simplified queries, it is sometimes handy to log the generated native queries for debugging purpose.

This can be achieved by setting to DEBUG the following log category inside your `application.properties`:

[source,properties]
----
quarkus.log.category."io.quarkus.mongodb.panache.runtime".level=DEBUG
----

== Transactions

WARNING: MongoDB offers ACID transactions since version 4.0. MongoDB with Panache doesn't provide support for them.
Expand Down Expand Up @@ -856,7 +867,6 @@ public Multi<ReactivePerson> streamPersons() {

TIP: `@SseElementType(MediaType.APPLICATION_JSON)` tells RESTEasy to serialize the object in JSON.


== How and why we simplify MongoDB API

When it comes to writing MongoDB entities, there are a number of annoying things that users have grown used to
Expand Down
15 changes: 15 additions & 0 deletions docs/src/main/asciidoc/mongodb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ Notice there's an extra bit in the key (the `users` and `inventory` segments).
The syntax is as follows: `quarkus.mongodb.[optional name.][mongo connection property]`.
If the name is omitted, it configures the default client.

[NOTE]
====
The use of multiple MongoDB clients enables multi-tenancy for MongoDB by allowing to connect to multiple MongoDB clusters. +
If you want to connect to multiple databases inside the same cluster,
multiple clients are **not** necessary as a single client is able to access all databases in the same cluster
(like a JDBC connection is able to access to multiple schemas inside the same database).
====

=== Named Mongo client Injection

When using multiple clients, each `MongoClient`, you can select the client to inject using the `io.quarkus.mongodb.runtime.MongoClientName` qualifier.
Expand Down Expand Up @@ -598,6 +606,13 @@ Currently, Quarkus doesn't support the `mongodb+srv` protocol in native mode.
link:https://docs.mongodb.com/manual/core/security-client-side-encryption/[Client-Side Field Level Encryption] is also not supported in native mode.
====

[TIP]
====
If you encounter the following error when running your application in native mode: +
`Failed to encode 'MyObject'. Encoding 'myVariable' errored with: Can't find a codec for class org.acme.MyVariable.` +
This means that the `org.acme.MyVariable` class is not known to GraalVM, the remedy is to add the `@RegisterForReflection` annotation to your `MyVariable class`.
====

== Conclusion

Accessing a MongoDB database from a MongoDB Client is easy with Quarkus as it provides configuration and native support for it.
Expand Down