I have this: A field which is a map where the keys are UUIDs and the value another object which is not relevant. A list of UUIDs that should be passed as parameter. I want to: delete from the collection all documents where all keys of the map are included in the list of UUIDs The object: With derived queries
Tag: spring-data-mongodb
Spring MongoDB Criteria: How to check that the List exists and contains object with specific value?
How to check that the List<Object> exists and contains an object of class whose partnerRole field value is equal to “CREATOR” and companyId field value is equals to “123”? Document class: My method for generating a List of Criteria. But that won’t work because I’m referring to partners as if it were a PartnerDocument object, but partners is actually a
Convert nested map fields to snake case
how to convert all the nested fields of the following object rendered as json to snake_case? Given it’s read as a org.bson.Document, jackson object mapper won’t work as it’s designed for POJOs and it’s not possible to have POJOs here as the records are schema-less Answer It can be easily done by adding a custom key serializer to SimpleModule, then
How to custom sort only specific results in Spring MongoDB?
Is it possible to sort only results that matches a condition in Spring Mongo? Let us say I have this data: Color Fruit Amount Orange Orange 23 Red Apple 4 Red Strawberry 66 Yellow Banana 2 I want to sort the list to display the Fruits with color red on Top and the remaining fruits will be sorted by amount.
spring-data-mongodb : Between change from ($gt, $lt) to ($gte, $lte)
In my repository I’ve added the following method : Generated query by spring-data-mongo is : [debug] 2020-09-11 15:39:59,550 – o.s.d.m.c.MongoTemplate – find using query: { “eventDate” : { “$gt” : { “$date” : 1577833200000 }, “$lt” : { “$date” : 1599775200000 } } } fields: Document{{}} for class: class xxxxxx Is there a way to tell spring data to use
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
Spring Data MongoDB 4.0 transactions support
MongoDB 4.0 are going to introduce transactions support with ACID guarantees. Does Spring Data MongoDB already supports the transactions in MongoDB and if no, when this awesome feature will be available. I really need it, taking into account the following issue – MongoDB schema design in order to support application horizontal scaling Answer Does Spring Data MongoDB already supports the
Change or override default Behavior of Mongorepository.save(document)
Is there any way to intercept or change the document before MongoRepository.save(e) updates it? I am trying to push a subproperty inside and array in a document. I have tried to manipulate DBObjects by implementing converter(using custom converter) but the $push operation did not work over there. I think to make it work I have to implement something like mongoOperation.update(dbObjectMatch,dbObjectUdate).
Spring Data MongoDB Annotation @CreatedDate isn’t working, when ID is assigned manually
I’m trying to use auditing to save dateCreated and dateUpdated in my objects, but since I set ID manually, there’s some additional work. Following Oliver Gierke’s suggestion in DATAMONGO-946 I’m trying to figure out how to correctly implement it. As original poster in Jira task above, I’ve downloaded example from here https://github.com/spring-guides/gs-accessing-data-mongodb.git and modified it a bit: and and a