Viktor
Posts: 0
Joined: Mon Jun 01, 2015 7:48 am

Query on pointer values

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!

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

Query on pointer values

Hello Viktor,

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

Viktor
Posts: 0
Joined: Mon Jun 01, 2015 7:48 am

Query on pointer values

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?

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

Query on pointer values

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

Viktor
Posts: 0
Joined: Mon Jun 01, 2015 7:48 am

Query on pointer values

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.

Viktor
Posts: 0
Joined: Mon Jun 01, 2015 7:48 am

Query on pointer values

Any idea?

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

Query on pointer values

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

Viktor
Posts: 0
Joined: Mon Jun 01, 2015 7:48 am

Query on pointer values

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

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

Query on pointer values

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

Return to “Issues”