Description
Issue Description
I have one question about querying objects
Example : I have a products class which has a pointer to Events class through the "event" field. I want to extract all the matched items from Products that belongs to the same Event.
Products class :
"results": [
{
"objectId": "LozokqgJQz",
"price": 9,
"name": "Entree + Conso",
"event": {
"__type": "Pointer",
"className": "Event",
"objectId": "QHIXTBECcv"
}
},
{
"objectId": "CDzofqgJQz",
"price": 10,
"name": "Entree + Conso",
"event": {
"__type": "Pointer",
"className": "Event",
"objectId": "FHIXTZZCcv"
}
},
{
"objectId": "DXzosqgJQz",
"price": 10,
"name": "Entree + Conso",
"event": {
"__type": "Pointer",
"className": "Event",
"objectId": "FHIXTZZCcv"
}
}
]
For example, for an event of objectId "QHIXTBECcv" the following item from Products class should be returned :
{
"objectId": "LozokqgJQz",
"price": 9,
"name": "Entree + Conso",
"event": {
"__type": "Pointer",
"className": "Event",
"objectId": "QHIXTBECcv"
}
Steps to reproduce
What I have done already :
const Product = Parse.Object.extend("Product");
const needle = {"__type": "Pointer", "className": "Event", "objectId": "QHIXTBECcv"};
const query = new Parse.Query(Product).equalTo('event', needle);
const results = await query.find();
//For showing the matched products
for (let i = 0; i < results.length; i++) {
var object = results[i];
alert(object.get('event') + ' - ' + ' Price ' + object.get('price'));
}
Expected Results
I want to be able to supply whatever event objectId to
const needle = {"__type": "Pointer", "className": "Event", "objectId": "QHIXTBECcv"};
instead of hardcoding it to "QHIXTBECcv"
I want some means of specifying a variable name.
something like :
const needle = {"__type": "Pointer", "className": "Event", "objectId": varobjectId};
but it's not working!
What is the correct syntax for doing that? or is there some other way of doing this whole thing?