javascript - How to order the GET response using loopback -
i've simple model looks this:
{ "name": "reason", "plural": "reasons", "base": "persistedmodel", "idinjection": true, "options": { "validateupsert": true }, "properties": { "title": { "type": "string", "required": true }, "position": { "type": "number", "required": true } }
when retrieving entries, order them per default position field value. best way go this? using model hook? how it? i'm not sure implementation.
you can add default scope model so:
{ "name": "reason", "plural": "reasons", "base": "persistedmodel", "idinjection": true, "options": { "validateupsert": true }, "properties": { "title": { "type": "string", "required": true }, "position": { "type": "number", "required": true } }, "scope": { "order": "position" } }
Comments
Post a Comment