REST in Parse $in to ObjectID of Pointer Error Cod

2019-05-22 06:30发布

问题:

I'm trying to get the following query:

https://api.parse.com/1/classes/Video?where=
{"course":{"__type":"Pointer","className":"Course","objectId":{"$in":["id1","id2"]}}}

I'm querying on Video table, on "course" field (It's a pointer) to get all videos that its course is one of ids passed in the array (For this reason I use $in) because if I don't use $in, I don't have problems but I don't need it.

The error is this:

{ 
   code: 106,
   error: "key objectId should be a string"
}

What I have to do? Do you have any idea??

Thanks

回答1:

You can try with the "$inQuery"

where={"course":{"$inQuery":{"where":{"objectId":{"$in":["id1","id2"]}},"className":"Course"}}}


回答2:

I've not used the rest API, but the guide indicates that you can compound conditions with $or, as follows...

https://api.parse.com/1/classes/Video?where={"$or":[
    {"course":{"__type":"Pointer","className":"Course","objectId":"id1"}},
    {"course":{"__type":"Pointer","className":"Course","objectId":"id2"}}
]}