Skip to content

Commit 3e2b877

Browse files
committed
Add withDocumentClass() to the ReactiveMongoCollection
1 parent 756c212 commit 3e2b877

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoCollectionImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,4 +820,9 @@ public Uni<Void> renameCollection(ClientSession clientSession, MongoNamespace ne
820820
public CodecRegistry getCodecRegistry() {
821821
return collection.getCodecRegistry();
822822
}
823+
824+
@Override
825+
public <NewTDocument> ReactiveMongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz) {
826+
return new ReactiveMongoCollectionImpl<>(this.collection.withDocumentClass(clazz));
827+
}
823828
}

extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/reactive/ReactiveMongoCollection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.List;
44

5+
import com.mongodb.client.MongoCollection;
56
import org.bson.Document;
67
import org.bson.codecs.configuration.CodecRegistry;
78
import org.bson.conversions.Bson;
@@ -1489,4 +1490,13 @@ Uni<Void> renameCollection(ClientSession clientSession, MongoNamespace newCollec
14891490
* @return the codec registry
14901491
*/
14911492
CodecRegistry getCodecRegistry();
1493+
1494+
/**
1495+
* Create a new ReactiveMongoCollection instance with a different default class to cast any documents returned from the database into..
1496+
*
1497+
* @param clazz the default class to cast any documents returned from the database into.
1498+
* @param <NewTDocument> The type that the new collection will encode documents from and decode documents to
1499+
* @return a new MongoCollection instance with the different default class
1500+
*/
1501+
<NewTDocument> ReactiveMongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz);
14921502
}

0 commit comments

Comments
 (0)