test.js 477 Bytes
Newer Older
박상호's avatar
박상호 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const inventory = {
    sibal: [
        { name: 'apples', quantity: 2 },
        { name: 'bananas', quantity: 4 },
        { name: 'cherries', quantity: 9 }
    ]
}


const result = inventory.find(fruit => fruit.name === 'cherries');
const what = inventory.find({},{ sibal: { $elemMatch: { quantity: 2 } } })

// db.schools.find( { zipcode: "63109" },
//                  { students: { $elemMatch: { school: 102, age: { $gt: 10} } } } )
console.log(result);
console.log(what);