0
我有一个使用一些嵌入式文档和一个引用文档的项目。我选择引用最后一个,因为它定期更新。在mongodb中引用文档
哪一种显示引用数据的文档是最好的方法?我已经看到两种方法:
1 - 查询mongodb的用于在每个文档 (例如,从http://www.mongodb.org/display/DOCS/Schema+Design)所引用的数据
student.scores[0].for_course = db.courses.findOne({_id:_course_id_to_find_});
2 - 查找整个参考文件,高速缓存的对象上,并(客户端),其引用的数据
db.courses.find({})
cachedCourses = {}
for course in courses {
cachedCourses[course._id] = course //object using id as key
}
student.scores[0].for_course = cachedCourses[_course_id_to_find_]