我仍然是MongoDB和非关系数据库的新手,所以如果我的问题的答案是“Dude,你正在以错误的方式考虑你的数据”,请告诉我。
话虽如此,这就是我所追求的。我有以下数据:
{
"_id" : ObjectId("549b26b370b452eeb6acecd3"),
"user" : "54530e03c575dc86d61d22f8",
"workHistory" : [
{
"description" : "",
"endDate" : null,
"name" : "My Company",
"skills" : [
{
"_id" : ObjectId("549b29c970b452eeb6acecd4")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecd5")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecda")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecdb")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecdd")
},
{
"_id" : ObjectId("549b29c970b452eeb6acece9")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecea")
},
{
"_id" : ObjectId("549b995b70b452eeb6acecf9")
},
{
"_id" : ObjectId("549b999470b452eeb6acecfa")
},
{
"_id" : ObjectId("549b9ab670b452eeb6acecfb")
}
],
"startDate" : "2013-10-01"
},
{
"description" : "",
"endDate" : "2013-10-01",
"name" : "Another Company",
"skills" : [
{
"_id" : ObjectId("549b29c970b452eeb6acecd4")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecd5")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecdb")
},
{
"_id" : ObjectId("549b29c970b452eeb6acecdd")
},
{
"_id" : ObjectId("549b29c970b452eeb6acece1")
},
{
"_id" : ObjectId("549b29c970b452eeb6acece9")
},
{
"_id" : ObjectId("549b995b70b452eeb6acecf9")
}
],
"startDate" : "2012-04-01"
},
.....
我要做的是解决这些数据,我可以列出“技能”下的实际技能名称,而不仅仅是对象ID。这里是技能收集的参考:
/* 0 */
{
"_id" : ObjectId("549b29c970b452eeb6acecd4"),
"name" : "CSS",
"description" : ""
}
/* 1 */
{
"_id" : ObjectId("549b29c970b452eeb6acecd5"),
"name" : "HTML5",
"description" : ""
}
/* 2 */
{
"_id" : ObjectId("549b29c970b452eeb6acecd6"),
"name" : "Ruby",
"description" : ""
}
/* 3 */
{
"_id" : ObjectId("549b29c970b452eeb6acecd7"),
"name" : "Ruby on Rails",
"description" : ""
}
我已经尝试过使用MapReduce来进行某种连接,但是我几乎无法绕过它并且我发现的所有examples都没有这么复杂的数据。
获得理想结果的最佳方法是什么?旁注:我并非100%确定只是将技能嵌入“技能”属性是正确的方法。我试图将它们分开,因为技能可能会在我的应用程序的其他区域中与工作历史分开列出。