Is there an api layer which could accept where condition json data as input parameter?
Since this is a must part behind restful api, so I think there must be something like this? But not sure if it is an api layer which could be used by developers?
I think the process flow on parse server side should be something like:
let whereJson = query.where; // {"score":{"$gte":1000,"$lte":3000}}
let result = XXX.findMethod(whereJson, GameScore); // return the query result with where filter
And now assuming that the 3000 can not be passed from client, which need to be calculated on server side based on APPLICATION_ID instead. To achieve this, seems we could only use cloud code? Something as below:
let lteValue = getLteValue(APPLICATION_ID); // maybe stored in the mongodb
let whereJson = query.where;
whereJson.score.$lte = lteValue; // construct the $lte attribute value on server side
let result = XXX.findMethod(whereJson, GameScore); // return the query result with where filter
So, my question is: is the XXX.findMethod or similar api (which accepts where filter json as input parameter) exists?
If still anything unclear, please just let me know. Thanks!
@davimacedo Thanks for kind help, I understood that I could use the beforeFind trigger, while just did not find the “findMethod” API in document, which could have the whereJson parameter.
I also found the fromJSON and withJSON, but not sure if they are related. And also, seems the doc for withJSON is not accurate, since the example there has NO withJSON wording, only fromJSON …