Page 1 of 1

Query on pointer values

Posted: Wed Oct 26, 2016 9:21 pm
by Viktor

Hi!

I have a collection with two pointers - to other collections. I have the collection with the pointers listed on a grid (or rather content from collections there pointing to). I also have a selectmenu and a searchbar. Values of selectmenu are column names in the other two collections. When I select something on the menu it's value is saved in local storage called "searchType_jobs". When a search is executed it invokes the search LIST service. With before send mapping of value of searchbar to query WHERE. With the following JS:

var searchtype = localStorage.getItem('searchType_jobs');
return '{searchType:{"$regex":"^'+value+'", "$options":"i"}}';

But I've understood that you can't do this type of regular query on pointer values. Anyone got any idea? All help appreciated!

Thanks!


Query on pointer values

Posted: Thu Oct 27, 2016 6:49 am
by Serhii Kulibaba

Hello Viktor,

Please look at the link below how to use queries with related objects : https://docs.appery.io/reference#data...


Query on pointer values

Posted: Thu Oct 27, 2016 11:44 am
by Viktor

Hi Sergly! Thanks for replying!

Originally tried this:

var searchType = localStorage.getItem("searchType_jobs");
return '{searchType: {"$inQuery", "$regex":{"productName": "^'+value+'", "$options":"i"}}}';

But didn't work at all. So simplified it and did this:

var searchtype = localStorage.getItem("searchType_jobs");
return '{searchtype: {"$notInQuery":{"productName": "'+value+'"}}}';

Here everything worked except the "searchtype". Is it possible to somehow use the first code?


Query on pointer values

Posted: Thu Oct 27, 2016 12:40 pm
by Serhii Kulibaba

Please send us a screenshot from the database page with it's structure, e.g.:
Image


Query on pointer values

Posted: Thu Oct 27, 2016 3:45 pm
by Viktor

Yes! Thanks!
Image

The selectmenu is to select the right pointer value/collection, then instead of having "productName" as in my previous comment its going to be a second value from local storeage.


Query on pointer values

Posted: Sat Oct 29, 2016 11:20 am
by Viktor

Any idea?


Query on pointer values

Posted: Mon Oct 31, 2016 8:06 pm
by Serhii Kulibaba

Sorry, but I don't see a column "searchtype" in your collection, so if you want to filter values of that collection by products, please use "jobProductID" instead of "searchtype" here


Query on pointer values

Posted: Tue Nov 01, 2016 4:01 pm
by Viktor

searchtype is a variable, the value of which is jobProductID or any other column.


Query on pointer values

Posted: Tue Nov 01, 2016 6:18 pm
by Serhii Kulibaba

You use it as a string, but not as a variable. Please use JS below for that:
prevar searchtype = localStorage.getItem("searchType_jobs");
var whereObj = {};
whereObj[searchtype] = {"$notInQuery":{"productName": value}};
return whereObj; /pre