Skip to content
Advertisement

Tag: mongodb

Mongo Replicaset monitoring replaces hostnames with IP and leads to failed hostname verification

we have a problem with the mongo java driver and the monitoring thread. We are running a 3 server replicaset and connect our spring boot microservices by using the hostnames. mongodb://<username>:<password>@A:27017,B:27017,C:27017/?tls=true Up until now we always used the non-reactive mongo driver and everything is working fine. However I now wanted to use the reactive/netty version and we’re getting a java.security.cert.CertificateException

Java Date to MongoDB date with Gson

Introduction I am currently working on a project that regularly saves several java objects to a MongoDB database. This object contains a Date. Problem The conversion of java Date to Json Mongo give this: But this format does not conform with MongoDB Date. MongoDB is considered as a string instead of a Date. Affected code Question How to create an

How to query mongodb with query Builder in java?

I need to make a query in java to MongoDB, how could I do it with QueryBuilder, this is my query: By the way, if anyone knows where I can find documentation to make these queries, I would appreciate it. Answer You should Refer this documentation Create a MongoCollection object. Create a list to have aggregate pipelines Aggregates is a

MongoDB – Update parts of object

I have the collection that stores documents per some execution Flow. Every Process includes “processes” and each process includes steps. So I end up with a ‘flows’ collection that has documents that look like this: A couple of notes here: Each flow contains many processes Each process contains at least one step, it is possible that in different processes the

MongoDB how to test locally in Java a MongoDB database, like H2 with sql database?

I’m developing a program that use MongoDB database but I’m asking if it is possible to use an internal database for test like H2 when doing SQL through Java? Answer You can try to use Testcontainers Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases. Or look at https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo Update: It seems that

MongoDB Extract document

I have this Json: I would like to filter exclusive for paymentType.type equals “PILOT” and limits equals type equals “COMBAT_HOURS”. This is the result I would like to receive. How to extract the document to reach this result? Answer Query map paymentTypes if paymentType= PILOT, filter the limits to keep only the combat hours else null (we don’t want that

Advertisement