Skip to content

PFQuery issue with NSpredicate #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
topslave opened this issue Aug 19, 2018 · 1 comment
Closed

PFQuery issue with NSpredicate #1330

topslave opened this issue Aug 19, 2018 · 1 comment

Comments

@topslave
Copy link

Hi,
I am building a chat application using Livequery, the chat works well with

      let predicate = NSPredicate(format:"itemID = '\(itemId1)' OR itemID = '\(itemId2)'")
        query = Message.query(with: predicate)?.order(byAscending: "createdAt")
       let query = PFQuery(className: MY_CLASS_NAME, predicate: predicate)

this works well if I don't use live queries and pull with time interval.
Livequery also works if I don't add predicate.
Below is the error I get
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (PFQuery)'

any ideas ?
Thanks

@flovilmart
Copy link
Contributor

Closing at the same issue is tracked there: parse-community/ParseLiveQuery-iOS-OSX#156

Feel free to open a PR.

As a work around, instead of making an $or query you can use the containedIn:

Message.query()?.whereKey("itemId", containedIn: [itemId1, itemId2])

This is more efficient also server side as it will be resolved in a single query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants