Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Order response by included Pointer

How can I sort my response by a field within an included pointer field ie.

[
{
"createdAt":"2013-03-29 16:06:34.517",
"id":"5155bc0ae4b00ae64e2678e5",
"updatedAt":"2013-05-27 21:24:46.047",
"maincontact":{
"createdAt":"2013-03-29 16:19:45.627",
"id":"5155bf21e4b00rr64e2611f2",
"updatedAt":"2013-05-27 21:35:09.468",
"birthdate":"1972-05-27 00:00:00.000",
"name":"Piet",
"surname":"Pompies",
"title":"Mr"
},
"othercontacts":[
"51a3ce35e4b00afhh5f8a1b4",
"51a3cjjfe4b00afed5f8a1b9"
],
"propertylinks":[
"5155c0c3e4byy8864e261243"
],
"type":{
"id":"5155bc2774b33ae64e2611e9",
"name":"Individual",
"createdAt":"2013-03-29 16:07:09.051",
"_updatedAt":"2013-03-29 16:07:09.051"
}
},
{
...
}
]

I'd like the response to be ordered by the maincontact.name.

Kind regards

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Order response by included Pointer

Hi,

If you get data from Appery.io Database add one more request parameter "sort".
Set "sort" value = "maincontact.name" for ascending or alphabetical order.
Use value = "-maincontact.name" for reverse order.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Order response by included Pointer

Interesting, I did try that but it did not affect the response.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Order response by included Pointer

I'm not sure what response you mean.
These links may also be helpful:
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Order response by included Pointer

Here's my response I'm referring to. As you can see the sort does not seem to work for some reason. I have added a request parameter 'sort' and tried both 'maincontact.name' and '-maincontact.name' but is does not make any difference.

[
{
"createdAt":"2013-03-29 16:06:34.517",
"id":"5155bc0ae4b00ae64e2611e5",
"updatedAt":"2013-05-27 21:24:46.047",
"maincontact":{
"createdAt":"2013-03-29 16:19:45.627",
"id":"5155bf21e4b00ae64e2611f2",
"updatedAt":"2013-05-27 21:35:09.468",
"birthdate":"1972-05-27 00:00:00.000",
"name":"Piet",
"surname":"Pompies",
"title":"Mr"
},
"othercontacts":[
"51a3ce35e4b00afed5f8a1b4",
"51a3cedfe4b00afed5f8a1b9"
],
"propertylinks":[
"5155c0c3e4b00ae64e261243"
],
"type":{
"collName":"clienttype",
"id":"5155bc2de4b00ae64e2611e9"
}
},
{
"createdAt":"2013-05-28 06:16:38.309",
"id":"51a44bc6e4b00afed5f8a23a",
"updatedAt":"2013-05-28 06:17:50.711",
"maincontact":{
"createdAt":"2013-05-28 06:17:13.021",
"id":"51a44be9e4b00afed5f8a23c",
"updatedAt":"2013-05-28 06:17:36.003",
"birthdate":"1954-05-01 00:00:00.000",
"name":"Koos",
"surname":"Harmse",
"title":"Mr"
},
"type":{
"collName":"clienttype",
"id":"5155bc2de4b00ae64e2611e9"
}
},
{
"createdAt":"2013-05-29 20:52:04.195",
"id":"51a66a74e4b00afed5f8a899",
"updatedAt":"2013-05-29 20:52:45.128",
"maincontact":{
"createdAt":"2013-05-29 20:51:20.886",
"id":"51a66a48e4b00afed5f8a897",
"updatedAt":"2013-05-29 20:51:45.420",
"birthdate":"1982-05-08 00:00:00.000",
"name":"Jan",
"surname":"De Wet",
"title":"Mr"
},
"type":{
"collName":"clienttype",
"id":"5155bc22e4b00ae64e2611e8"
}
},
{
"createdAt":"2013-05-29 21:03:33.025",
"id":"51a66d25e4b00afed5f8a8aa",
"updatedAt":"2013-05-29 21:03:38.728",
"maincontact":{
"createdAt":"2013-05-29 21:02:41.154",
"id":"51a66cf1e4b00afed5f8a8a8",
"updatedAt":"2013-05-29 21:03:17.436",
"birthdate":"1954-01-29 00:00:00.000",
"name":"James",
"surname":"Stuart",
"title":"Mr"
},
"type":{
"collName":"clienttype",
"id":"5155bc22e4b00ae64e2611e8"
}
},
{
"createdAt":"2013-05-29 21:08:08.434",
"id":"51a66e38e4b00afed5f8a8ad",
"updatedAt":"2013-05-29 21:09:09.128",
"maincontact":{
"createdAt":"2013-05-29 21:05:55.086",
"id":"51a66db3e4b00afed5f8a8ab",
"updatedAt":"2013-05-29 21:07:12.708",
"birthdate":"1993-05-29 00:00:00.000",
"name":"Kate",
"surname":"Crawford",
"title":"Miss"
},
"type":{
"collName":"clienttype",
"_id":"5155bc2de4b00ae64e2611e9"
}
}
]

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Order response by included Pointer

We'll test this but this will take time.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Order response by included Pointer

Thank you very much.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Order response by included Pointer

Hello! There is no possibility to sort your response this way because maincontact is a pointer to another table. That's why it doesn't sort by field. To get it working you can use Generic service (here is more information https://getsatisfaction.com/apperyio/...)

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Order response by included Pointer

I know this is old, but this is exactly what I am trying to do. Could you please clarify on how I could use a generic service to sort on a pointer to another table just like the OP asked here?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Order response by included Pointer

Hello,
Please use sort() method for such functionality: http://stackoverflow.com/questions/12...

Return to “Issues”