I have a mongodb collection which looks like this
[
{
pId: "p1",
apikey: "a2",
count: 0
},
{
pId: "p2",
apikey: "a2",
count: 0
},
{
pId: "p2",
apikey: "a3",
count: 0
}
]
I have an input which is array of object. I want to increment the counts. The input objects are like below
[
{
pId: "p1",
apikey: "a2"
},
{
pId: "p2",
apikey: "a2"
}
]
this above 2 input objects matches with the first 2 objects present in the collection. i was incrementing by iterating the input array. Is there any other way to achieve this?
pId
orapiKey
or both? 2) what if an element no found?