3
假設我們有這些模型:Mongoid:檢索所有嵌入文檔
class Person
include Mongoid::Document
embeds_many :albums
end
class Album
include Mongoid::Document
embeds_many :photos
end
class Photo
include Mongoid::Document
end
我想要的是檢索特定Person
的所有Photo
。是否有一個mongoid/mongodb快捷方式或唯一的方法是迭代person.albums
並將所有album.photos
存儲在一個新數組中?
謝謝。
在第二種情況下,照片將是「照片」或「哈希」? – Iazel
第二種情況你將只有哈希值。 –