From 2ab610c3b428d95615d9f06f952be998a8bc7be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Fri, 10 Apr 2020 10:45:45 +0200 Subject: [PATCH] MongoDB documentation improvements --- docs/src/main/asciidoc/mongodb-panache.adoc | 12 +++++++++++- docs/src/main/asciidoc/mongodb.adoc | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/mongodb-panache.adoc b/docs/src/main/asciidoc/mongodb-panache.adoc index 7520e0fa0fa00..474dc668c89bd 100644 --- a/docs/src/main/asciidoc/mongodb-panache.adoc +++ b/docs/src/main/asciidoc/mongodb-panache.adoc @@ -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. @@ -856,7 +867,6 @@ public Multi 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 diff --git a/docs/src/main/asciidoc/mongodb.adoc b/docs/src/main/asciidoc/mongodb.adoc index 3f907fd962d54..dd0c1926197c2 100644 --- a/docs/src/main/asciidoc/mongodb.adoc +++ b/docs/src/main/asciidoc/mongodb.adoc @@ -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. @@ -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.