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 obje开发者_C百科ctID 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.
Posted the same question in the Spring forums, and one of their community members responded:
http://forum.springsource.org/showthread.php?113968-resolving-simple-mongodb-references-in-spring-w-o-dbref
We have to do the join ourself on the client side, if we don't use dbref.
精彩评论