Sorting 2018-10-08T15:25:43+08:00

Sorting

To sort the API query result by specify field, use the  sort_by query parameter.

ParameterRequiredDescriptionTypeFilter TypeExamples
sort_byoptionalTo sort API query result by a specific field.

  • By default, it is sorted by ascending order.
  • To obtain result in descending order:
    • Adding “-” (minus sign) in front of the field name
querysimplesort_by=accessDate
sort_by=-accessDate

Examples

Sort by ascending order

Suppose you want to obtain the access control records in ascending order. You initially pass parameter sort_by=accessDate to the endpoint and retrieve the earliest records of the dataset.

Request

http://api.data.um.edu.mo/service/facilities/access_control_records/v1.0.0/all?sort_by=accessDate

Response (truncated)

{ "_embedded": [
{"_id":"5b681899daa27829cddf67d3","hashID":"196872114d6cbe6af7e446b15c181183","doorID":"S03-0G-C04","accessDate":"2016-08-06T17:33:59+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d4","hashID":"2d1be5639d9739ef64f30f388e217204","doorID":"S03-C2 TURNSITLE OUT","accessDate":"2016-08-06T17:34:04+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d5","hashID":"2a5bbbabe1cb09a9b210875129e761b7","doorID":"W22 TURNSTILE R (I)","accessDate":"2016-08-06T17:34:35+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d6","hashID":"f3b2a479d632bb8f972ab5c6f6181378","doorID":"S02-TURNSTILE IN","accessDate":"2016-08-06T17:34:37+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d7","hashID":"2ac9076c441a0b2c1fd697b067d6e69c","doorID":"S03-0G-C01-01","accessDate":"2016-08-06T17:35:14+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d8","hashID":"7f2f09c1f782f0129ad9d347a410473c","doorID":"S04 TURNSTILE IN","accessDate":"2016-08-06T17:35:37+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67d9","hashID":"9a72961d18f1b2ffdf8648d5b552ead6","doorID":"S09-TURNSTILE L OUT","accessDate":"2016-08-06T17:35:42+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67da","hashID":"2f9f0d778ab4f71f2e2365ee5291de59","doorID":"S03-C2 TURNSTILE IN","accessDate":"2016-08-06T17:35:47+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67db","hashID":"a7dc2ee48a5253cd38e50e402e990591","doorID":"S03-0G-C04","accessDate":"2016-08-06T17:35:53+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67dc","hashID":"e8618659bfeabbd890c750806e1c23a0","doorID":"S03-C2 TURNSTILE IN","accessDate":"2016-08-06T17:35:54+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67dd","hashID":"cd56ed0d57e55895927569ef516860d5","doorID":"S02-TURNSTILE IN","accessDate":"2016-08-06T17:36:07+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67de","hashID":"cbd1ad7f9d38fdc063f90f5fbdc35fde","doorID":"S03-0G-C01-01","accessDate":"2016-08-06T17:36:10+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67df","hashID":"cfd64eb57d2c936107ee2b1a062a0d9a","doorID":"S02-TURNSTILE OUT","accessDate":"2016-08-06T17:36:12+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67e0","hashID":"cfd64eb57d2c936107ee2b1a062a0d9a","doorID":"S02-TURNSTILE OUT","accessDate":"2016-08-06T17:36:13+08:00","grantResult":"G"},{"_id":"5b681899daa27829cddf67e1","hashID":"cfd64eb57d2c936107ee2b1a062a0d9a","doorID":"S02-TURNSTILE OUT","accessDate":"2016-08-06T17:36:14+08:00","grantResult":"G"},
...

Sort by descending order

Suppose you want to obtain the latest access control records, you would like to sort the result in descending order. You initially pass parameter sort_by=-accessDate to the endpoint and retrieve the latest records of the dataset.

Request

http://api.data.um.edu.mo/service/facilities/access_control_records/v1.0.0/all?sort_by=-accessDate

Response (truncated)

{ "_embedded": [
{"_id":"5bb984fe6f517c6891a53313","hashID":"914c632465396f59835cc6855d843714","doorID":"W13-0G-C04","accessDate":"2018-10-06T09:11:25+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980df","hashID":"75fd0376c8b53ffcbb818d7623d3bc73","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:09:11+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980de","hashID":"19d9f539e2c935cb553b65882c693a26","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:07:26+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980dd","hashID":"4aa4dfc657335163c999380463279e27","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:06:55+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980dc","hashID":"9bac403087e5b4a446c3275a024c493e","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:04:43+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980db","hashID":"81586047bbceb8071344b9082072d2f8","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:04:11+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980da","hashID":"f08f794a8658d9632e66903e06340953","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T09:02:54+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d9","hashID":"0fc12eeb4dcdae880275f1eb6b1bcae0","doorID":"W13-0G-Carpark","accessDate":"2018-10-06T08:58:39+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d8","hashID":"914c632465396f59835cc6855d843714","doorID":"W13-0G-C04","accessDate":"2018-10-06T08:55:33+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d7","hashID":"af1fb809237792b92b5f99cccd9bea14","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T08:52:43+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d6","hashID":"07399a0cabe8bbcb5383a5978159a10c","doorID":"W11-0G-C04","accessDate":"2018-10-06T08:52:02+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d5","hashID":"12cca474f86ad6ee06c59263daa7b85d","doorID":"W12 New Turnstile R Out","accessDate":"2018-10-06T08:49:53+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d4","hashID":"cd4954dfce28a84a261426af6198f930","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T08:49:12+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d3","hashID":"c2ad9a937164dc782c9dc211af3afe08","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T08:48:56+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d2","hashID":"42f0cf9fc9b042744fdb594383395301","doorID":"W12 New Turnstile L Out","accessDate":"2018-10-06T08:48:36+08:00","grantResult":"G"},{"_id":"5bb833816f517c4279a980d1","hashID":"2e1d50a30d22f2128244d2c05a406005","doorID":"W14-0G-Backdoor","accessDate":"2018-10-06T08:47:39+08:00","grantResult":"G"},
...

NOTE:

Sort operations that do not use an index will abort when they use 32 megabytes of memory. To check if the field is indexed or not, please refer to the “Indexed” filed in related data dictionary.

Ifpagesizeandpageare not given in the query string, a maximum of first 100 objects will be returned. Details please refer to “Pagination“.