1

I have collection like this

{
    "_id" : ObjectId("5adc0f2b2fabb719699ff257"),
    "name" : "Anil",
    "mobile" : 8108582645,
    "packages" : [
        {
            "totalAmount" : 6000,
            "purchaseDate" : ISODate("2018-04-22T04:00:00Z"),
            "expiryDate" : ISODate("2018-10-22T04:00:00Z"),
            "name" : "six month",
            "_id" : ObjectId("5adc0f2b2fabb719699ff258"),
            "isActive" : true,
            "paid" : 1000
        }
    ]
}
{
    "_id" : ObjectId("5adc0f862fabb719699ff259"),
    "name" : "Mahesh",
    "mobile" : 9877110154,
    "packages" : [
        {
            "name" : "six month",
            "expiryDate" : ISODate("2018-10-22T04:00:00Z"),
            "purchaseDate" : ISODate("2018-04-22T04:00:00Z"),
            "totalAmount" : 6000,
            "_id" : ObjectId("5adc0fa72fabb719699ff25b"),
            "isActive" : true,
            "paid" : null
        }
    ]
}

and I want all collection where package.paid === package.totalAmount

in Sql we do like this:

select * 
from packages
where paid=total;

in short I want all user who paid for there package.

Sunil Patel
  • 265
  • 3
  • 13

0 Answers0