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

Best way to filter collection queries

So just to confirm Yurii, I need to use a generic security context and implement server code?

I created a generic security context and went into the settings for my query service and selected the security context I created for the Security context field. However I haven't worked with security contexts before so my implementation code is just
pre
$t.Multilevel = $t.createClass(SecurityContext, {
invoke: function(service, settings) {
//Do any logic before call
$t.Multilevel.$super.invoke.call(this, service, settings);
//Do any logic after call
}
});
/pre
Does this code require any logic? And how do I change the response to multilevel?

Your help is much appreciated.

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

Best way to filter collection queries

Hi Colten,

pre

So just to confirm Yurii, I need to use a generic security context and implement server code?

/pre

Nope - you need to choose one of these options.

It's better for your to use server code instead of security context.

Please pass following tutorial to understand how it works: http://devcenter.appery.io/tutorials/...

Also you can find more details about server code here:
http://devcenter.appery.io/documentat...

As a conclusion - this server code should return multilevel JSON that will reflect to multilevel components lists/collapsible/grids..

Regards.

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

Best way to filter collection queries

Thanks for the info Yurii,
I read all the documentation on server code on the appery website. Your previous example however is a bit confusing to me. My database is set up like the following Image
As you can see a single 'deal' encompasses data from multiple lines, and is not a single column.

My starter code for the server code is the following
pre
var DB_id = "53cxxxx78c4b8db4d5" ;
var collectionName = "DealCollection";

var query = [];

query = Collection.query( DB_id , collectionName);

var result = [];

for( var i = 0 ; i < query&#46;length ; i++) {
result&#46;push ( {Location:query&#46;LocationID, id:query&#46;id });
}
response&#46;success(result);
/pre

I am assuming I will need more loops and possibly more arrays to form the correct response. The whole aim of doing this is to have only one call to the server to get all the information rather than setting up a different collection for each location and having a call for each location.

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

Best way to filter collection queries

So just to follow up, I created the correct response via server code. I had to put my collapsible blocks in a grid, now everything appears to work just fine.

Here you can see a test response
Image
Here is the successful server code for anyone interested
Image

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

Best way to filter collection queries

Hello Colten,

Thank you for the update.

Return to “Issues”