yoyojs
yoyojs

Reputation: 1773

retrieve items from a mongodb collection in meteor

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

Upvotes: 0

Views: 38

Answers (1)

durrrr
durrrr

Reputation: 352

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"});

Upvotes: 1

Related Questions