Announcement Announcement Module
No announcement yet.
resolving simple mongodb references in spring w/o dbref Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • resolving simple mongodb references in spring w/o dbref

    Let's assume that I have the following documents in mongodb in the employees collection:

    db.employees.insert({_id: ObjectId("4d85c7039ab0fd70a117d733"), name: 'Siona', manager: [ObjectId("4d85c7039ab0fd70a117d730"), ObjectId("4d85c7039ab0fd70a117d732")]})

    Here, 'Siona' has two managers, indicated in the managers array. I know that Spring Data M3 has the concept of DBRefs, but the monogdb documentation indicates that DBrefs are expensive, and that we should just store ObjectId when possible.

    My question is, is there any way to resolve the document that the objectID here is pointing to via the Spring Data Document api, or am I forced to perform a join on the client side, where:
    • We get the document that has the name:"Siona"
    • Go back to the database to resolve each of the ObjectId's that represent Siona's managers.