i have some embedded documents. Company -> Stand -> Product. Document product have field "tag". I can do this request very well: Company.where("stands.products.tags" => 开发者_如何学Python"books") but i want to find with two tag names, for example,
Company.where("stands.products.tags" => "books").where("stands.products.tags" => "toys"), but in this example mongo will find only "toys tags". How i can find more tags in one request?
I suggest you refactor your tags
attribute into an array of strings, index them and then have a look at this helpful method
Company.any_in("stands.products.tags" => ["books", "toys"])
精彩评论