0
我一直在使用這樣的Mongoid和MongoDB查詢
Courses
{
"name" : "Course1",
"student_id"
"subjects" :
[{
"level" : "1",
"short_name" : "Maths",
"topics" : [{
"name" : "Algebra 101",
"week" : "1",
"submission_week" : ISODate("2013-07-28T00:00:00Z"),
"correction_week" : ISODate("2013-07-28T00:00:00Z")
},
{
"name" : "Algebra 201",
"week" : "1",
"submission_week" : ISODate("2013-07-28T00:00:00Z"),
"correction_week" : ISODate("2013-07-28T00:00:00Z")
}
]},
{
"level" : "2",
"short_name" : "Chem"
}
]
}
數據晶格結構Mongoid我試圖找回所有主題。
我試過各種查詢,但似乎無法得到它。
例如,我不明白爲什麼這不起作用?
Topic.where(name: "Algebra 101", 'subject.short_name' =>"Maths", 'subject.course.name' =>"Course1")
我可以這樣查詢嗎?
我的Ruby代碼是
class Course
embeds_many :subjects
class Subject
embedded_in :course
embeds_many :topics
class Topic
embedded_in :subject
歡呼那是什麼我擔心 – dboyd68