Page 1 of 1

Query on multiple included pointer objects

Posted: Sun Oct 09, 2016 9:55 am
by leven.steve

I'm trying to query the DB which will return only one row based on two included collections _id values. The DB structure has two Pointer objects for Scheme and Employee

Firstly I'm not clear if I need to use $inQuery or not?
If I test $inQuery in the Database query screen like this for just one of the values:
{"$inQuery":{"Scheme._id":"56d86cc2e4b0600060a4baeb"}}
I get this error:
Mongo error: 'Can't canonicalize query: BadValue unknown top level operator: $inQuery'
Why am I seeing this error? Where is my syntax wrong please ?

So I figured that perhaps $inQuery as per the documentation here isnt available any more or the documentation is wrong?
https://docs.appery.io/reference#data...

So now I try without $inQuery and this works and returns 5 rows as expected.
{"Scheme._id":"56d86cc2e4b0600060a4baeb"}

Now I want to get that down to 1 row return by specifying the Employee id as well so I try this query in the database query page:
{"$and":[{"Scheme.id":"56d86cc2e4b0600060a4baeb"},{"Employee._id":"57f8e447e4b0d305965d6326"}]}
and I get back one row. So that's good.

On the page JS code I couldn't work out a way to use mapping to achieve this using the $scope variable for selectedScheme.id and selectedEmployee.id and drag/drop to the "where" clause.

I tried it like this and get nothing returned (the _id values for both pointers ARE correct and worked in the DB query screen.

Therefore, is this really the best way to format the where clause or is there and better/quicker/easier way?
Same question would apply if there was just one included Pointer _id query

code
requestData.params.where = '{"$and":[{"Scheme.id":"'+selectedScheme_scope.id+'"},{"Employee.id":"'+selectedEmployee_scope.id+'"}]}';
/code


Query on multiple included pointer objects

Posted: Sun Oct 09, 2016 6:00 pm
by leven.steve

Any idea on this please? I need to move on with development ASAP.
Thx


Query on multiple included pointer objects

Posted: Mon Oct 10, 2016 7:33 am
by Serhii Kulibaba

Hello Steve,

Please look at this documentation page how to use pointer queries:
https://docs.appery.io/reference#data...

So your query should be like:
pre
requestData.params.where = {"$and":[
{"Scheme":{"collName":"Schemes", "id":selectedScheme_scope.id}},
{"Employee":{"collName":"Employees","id":selectedEmployee_scope.id}}
]};/pre

here Schemes and Employees - names of collections