Sort by multiple fields by priority?

I need to sort a list of documents so that it first shows all documents with a boolean field set to true, and than subsequent documents are ordered by a createdAt date.

Is this possible?

this sorts the boolean:

let sortBy = {sort: {myBool: -1}}

this sorts the date:

let sortBy = {sort: {createdAt: -1}}

but this seems to only sort by the boolean:

let sortBy = {sort: {myBool: -1, createdAt: -1}}

That should work - what are you seeing?

1 Like

It seems like it is showing is sorting the boolean correctly (they show up at the top of the list) but then after that the dates are not sorting. I’ll have to take another look I guess.