I have a database of objects that contain codes like 'A-123' and 'S-123'. And I need to sort this so that the objects with a code that starts with 'S-' should come first. Everything should then be sorted by date as well.
So far I've only found how to select objects that contain a string that starts with a particular letter, but I have not been able to sort on that while sorting on the date as well.
{code: {$regex: /^S-./}}