1

I have a ArrayList<String> -named listObjectId below- of objectIds. I'm trying to get all the objects that have an objectId contained in the ArrayList.

The solution I have right now, I think, is very bad from a performance point of view:

for (int i = 0; i < listObjectId.size(); i++) {
    ItemModel mItemModelRetrieved = null;
    ParseQuery<ItemModel > query = ParseQuery.getQuery(ItemModel .class);

    try {
        mItemModelRetrieved = query.get(listObjectId.get(i));
        subscriber.onNext(mItemModelRetrieved ); //-- I'm using RxJava
    } catch (ParseException e) {
        Log.e(TAG, "Error Local " + e.getMessage());
    }

}

2 Answers 2

3

You're using the wrong method. You have the object ids, so create a ParseObject with them using ParseObject.createWithoutData and then fetch the object. Try the following:

List<ParseObject> parseObjects = new ArrayList<>();
for (String objectId : listObjectId) {
    parseObjects.add(ParseObject.createWithoutData(ItemModel.class, objectId));
}

ParseObject.fetchAll(parseObjects);
// parseObjects will now contain all data retrieved from Parse.
Sign up to request clarification or add additional context in comments.

Comments

0

The error you're getting tells you that the data type of the column you query must be of type Array, not the value you pass into the method.

1 Comment

Thanks. I just updated my question. I think my solution is not great, do you see a better way to retrieve a list of objects ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.