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