Mongodb check if same child object exists in collection

71
February 11, 2021, at 10:00 AM

I need to find object if it exists. Collection is as below:

    {
  id: 1,
  names: {
     0: {city:"abc",id:1},
     1: {city:"def",id:2}
  }
},{
  id: 2,
  names: {
     0: {city:"ghi",id:3},
     1: {city:"def",id:2},
     2: {city:"abc",id:1}
  }
},{
  id: 3,
  names: {
     0: {city:"pqr",id:6}
  }
}

If I try to add name in the collection with cities 'abc' and 'def' then it should find that object as it exists if in the same order.

{
  names: {
     0: {city:"abc",id:1},
     1: {city:"def",id:2}
  }

Above should return find result as it exists.

{
  names: {
     0: {city:"def",id:2},
     1: {city:"abc",id:1}
  }

Above should not return find result as the order of cities is different and does not exist in the collection.

READ ALSO
In Django is it possible to send data from a view to itself when a page is refreshed

In Django is it possible to send data from a view to itself when a page is refreshed

Is there a way to know which buttons are pressed in a page when returning to a view in Django?

59
javascript multiple rating svg star click

javascript multiple rating svg star click

I have a rating star animation, on click should make the parent(span) active with a classI have multiple rating and I have the star 1 to 5 rating with also the half rating should work

73
The xlabels and xtick labels overlap between subplots in matplotlib. How to solve it?

The xlabels and xtick labels overlap between subplots in matplotlib. How to solve it?

The xlabels and xtick labels overlap between subplots as shown in the figureI am trying to use tight_layout() and plt

78
ANDROID REPLAY TOUCH EVENTS [closed]

ANDROID REPLAY TOUCH EVENTS [closed]

Want to improve this question? Update the question so it's on-topic for Stack Overflow

93