Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

Hi,
I currently have a collection with 'deals', and each deal includes the properties, Date and LocationID. I have a page with a date picker that picks a date and invokes the query. I use a where clause (via javascript in the where return value in the mapping) to get only the 'deals' with the correct date. This part works fine.

The deals are listed in a list that is nested within a collapsible block. There are multiple collapsible blocks each representing a location. I need to somehow sort all the deals that I get with the correct date to their corresponding list/collapsible block based on their LocationID. What is the best way to do this?

I've attached a screenshot of the page. Currently I've only implemented one collapsible block, so all deals in the collection go there. Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Best way to filter collection queries

Hello!

Could you please share print screens with your mapping?

Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

Here are the maps of before send and success for the query service
Image
Image

Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

I can probably get it to work by somehow mapping the $ to the other collapsible blocks and then using ' value.LocationID ' in the javascript to make a conditional test. But not sure if that would work.

Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

Any insight on how to do something like this?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Best way to filter collection queries

Colten,

We are working on it and will get back to you with the update.

Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

Thank you very much

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Best way to filter collection queries

HI Cotten,

How do you populate list of collapsibles(locations)?

If do it in accordance to DB(dynamically) - you can not do it with standard DB service cause of these services returns single entity response list.

To build multilevel lists - you need to have multilevel service response.

You have here two main directions:

  1. Use generic security context. Inside this context you will change response to multilevel.

  2. Use server code to build multilevel response.

    Example of multilevel response that you need:

    precode

    [

    { locationName: "location1",
    deals: [
    {name: "deal1"},
    {name: "deal2"}
    ]
    },

    ........

    ]

    /code/pre

    Regards.

Colten Tenney
Posts: 0
Joined: Thu Sep 25, 2014 3:41 am

Best way to filter collection queries

Thanks
I wish there was more documentation explaining multilevel responses. Is it true that adding an array column to a collection will enable a multilevel response as described here
https://getsatisfaction.com/apperyio/...
However I don't think this array method will work with my setup without a complete overhaul.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Best way to filter collection queries

Hi Cotten,

Custom service could return any response. With Appery.io REST services you can not get such response(in your case). Thus you need create this response yourself.

Here is a more detailed response example:

pre

[
{
locationName: "location1",
deals: [
{name: "deal1"},
{name: "deal2"}
]
},

Code: Select all

{ 
    locationName: "location2", 
    deals: [ 
       {name: "deal4"}, 
       {name: "deal6"} 
    ] 
}, 

{ 
    locationName: "location3", 
    deals: [ 
       {name: "deal11"}, 
       {name: "deal25"} 
    ] 
}, 

]

/pre

So here is an array(first level) of objects with other array(second level) inside.

Regards

Return to “Issues”