0

I have a collection "vegetables" who has many vegetables inside like this one :

vegetables = [{
            nom: "zuchini",
            recolte: [{
                month: ["august", "november", "december"],
                desc: ""
            }]

I want to find all vegetables who have for example "august" in the array "month, if i do for example :

Vegetables.find({ recolte[0].mois : "august});

i have an error when i do this...do u know how i can access to this element ?

thanks by advance

yoyojs
  • 1,723
  • 5
  • 24
  • 41
  • Seems like a duplicate of [this](http://stackoverflow.com/questions/18148166/find-document-with-array-that-contains-a-specific-value). In your case, I think the problem is the `[0]`. I don't think this is needed. – CodeChimp Oct 04 '16 at 16:51
  • it's not a duplicate because here it' different problem, it's an object inside an array and without the [0] i also have an error... – yoyojs Oct 04 '16 at 17:35
  • So, is `Vegitables` a collection or an object? – CodeChimp Oct 04 '16 at 18:43

1 Answers1

1

If Vegetables is a collection:

Vegetables.find({"recolte.month": "august"});

If Vegetables is a collection and it also has a vegetables field:

Vegetables.find({"vegetables.recolte.month": "august"});
durrrr
  • 352
  • 2
  • 15