Skip to content
Advertisement

Tag: mongodb

How to count array elements properly with multiple aggregation in Spring Data MongoDB?

I need to create advanced aggregation using Spring Data MongoDB having model like that: pom.xml Cities collection: Libraries collection: Books collection: Depending on the context of the user, I have to return cities with count of libraries and books in the city that can be filtered based on startsWith() or like() principle. Assuming that I have 2 libraries in one

How to get list of data containing count of a field using Aggregation and Criteria in Spring Boot with MangoDB

Requirement: documents-bookdata collection may have multiple objects with same bookPublisherName but different bookName. Means multiple books can have same publisher so need to extract count of books per publisher . Model class: Response format pojo Response Format Answer This requirement can also be done logically ..like get the list of DocumentsBookdata using findAll and than filter it using loop and

Mongo aggregate sum of two Strings

I am trying to sum one field in Mongo. If it is an Integer there is no issue, but the problem is that it is String and I get 0 for totalAmount amountField is a String, how can I sum it in this implementation Answer You are getting String amountField. Simply you can convert this String to Integer by using

Spring boot / Java, mongodb SSL / TLS connectivity

I have two projects where I use spring boot + mongodb. In one project the spring boot version is 1.4.1.RELEASE and other project is 2.1.3.RELEASE. I have certificate(s), key in PEM format to onboard into truststore and keystore – One server certificate chain and other a client certificate and private key. I programmatically load the certificates into truststore and keystore.

Connecting to mongoDB in spring boot causes errors

I want to connect to mongoDB Atlas in a spring boot project, but always Exceptions are thrown. If I use Java without spring boot, everything works fine. The following test project reproduces the errors. The pom.xml: The Main-class: And the configuration for mongoDB: The uri for mongoDB is stored in application.properties. If I start the server, the following exeception is

Advertisement