MongoDB sorting by nested object value MongoDB sorting by nested object value mongodb mongodb

MongoDB sorting by nested object value


When using dot notation you need to put the key value in quotes, so your sort object should look like this instead:

sort: {    "items.date" : 1}

That will sort ascending by minimum date value in each doc's items array