Search code examples
loopback

LOOPBACK: order by YEAR of a date


So, I have a model with a property of type date, let's say it's:

"start_date": {
  "type": "date",
  "required": true
}

when I get the information from this model, I would like to order by Year of that date

so instead of doing

{
    "order": [
        "start_date ASC"
    ]
}

I would like something like

{
    "order": [
        "dateYear(start_date) ASC"
    ]
}

is this possible?


Solution

  • If to check DataAccessObject._normalize() function (dao.js in loopback-datasource-juggler), loopback do nothing special with order property of a filter and pass the result to a datasource connector.

    So, looks like loopback doesn't support it. The only way to get this functionality, it should be supported by your datasource connector.