0

The mongoDB document is shown as below

{
    "_id" : ObjectId("5a79b826324a9a48356ta233")
    "name": "XYZ",
    "products": [{
        "_id": ObjectId("60d75e6f0095ee2d6469158c")
    }, {
        "_id": ObjectId("60d75e6f0095ee2d6469158e")
    }],
    "notes": "Times new Roman",
    "_class": "com.example.com"
}

I just wanted to remove one of the _id in the products array by passing the id value as the input. Consider removing "_id": ObjectId("60d75e6f0095ee2d6469158c") so I would just pass id value 60d75e6f0095ee2d6469158c. The resultant document should be as

{
    "_id" : ObjectId("5a79b826324a9a48356ta233")
    "name": "XYZ",
    "products": [{
         {
        "_id": ObjectId("60d75e6f0095ee2d6469158e")
    }],
    "notes": "Times new Roman",
    "_class": "com.example.com"
}

So I just need value for @Query() annotation that would be mentioned over an abstract method defined in a AbcRepository extending MongoRepository so that I could remove the required _id from the products

Referring to this I could see only the CLI operation in command shell something similar to this

This involves using a driver and writing a query as template

but I do required the operation with the help @Query() annotation in Spring Boot.

Krithick S
  • 139
  • 1
  • 12

0 Answers0