Alejandro Lora
Alejandro Lora

Reputation: 7802

REST in Parse $in to ObjectID of Pointer Error Code 106

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

Upvotes: 2

Views: 242

Answers (2)

Remo H. Jansen
Remo H. Jansen

Reputation: 24979

You can try with the "$inQuery"

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

Upvotes: 1

danh
danh

Reputation: 62676

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"}}
]}

Upvotes: 1

Related Questions