ChatGPT
ChatGPT

Reputation: 5617

how to do an order in this mongodb aggregate function

I want to do a single query for status: 'CLOSED' $or 'PAID_IN_FULL'

read the docs and tried all kinds of things, but can't seem to get the syntax right

{
    'lineItems.url': /.*mercari.*/i,
    status: 'PAID_IN_FULL',
    createdAt: {
        $gte: ISODate("2019-01-01T00:00:00.000Z"),
        $lt: ISODate("2019-12-20T00:00:00.000Z")
    }
}

{
    'lineItems.url': /.*mercari.*/i,
    status: 'CLOSED',
    createdAt: {
        $gte: ISODate("2019-01-01T00:00:00.000Z"),
        $lt: ISODate("2019-12-20T00:00:00.000Z")
    }
}

Upvotes: 0

Views: 31

Answers (1)

Kruti Choksi Patel
Kruti Choksi Patel

Reputation: 419

{
 'lineItems.url': /.*mercari.*/i,
  $or : [
  {  status: 'CLOSED' },
  {  status: 'PAID_IN_FULL' },
 ],  
 createdAt: {
  $gte: ISODate("2019-01-01T00:00:00.000Z"),
  $lt: ISODate("2019-12-20T00:00:00.000Z")
 }
}

Upvotes: 1

Related Questions