A Look at PFQuery

Aug 27, 2012 | Android, Apps, iOS, Java, Objective-C, Programming, Tools

Querying data is a pretty common task for most if not all mobile apps. iOS and Android have made the work pretty easier for developers, but Parse has thrown their hat into the ring to make it even easier for developers who choose to use their development tools and backend system; yes, I know this sounds a little like a commercial, but I am genuinely excited about this functionality and no I have no business or personal relationships with Parse or anyone therein.

PFQuery is a simple class that, as its name suggests, allows you to query your Parse dataset and getting data returned based on certain criteria. No need to stand on ceremony, let’s take a look at some code:



- (void) someMagicalFunction {
    PFQuery* query = [PFQuery queryWithClassName:@"SomeClass"];
    [query whereKey:@"SomeProperty" equalTo:@"MagicString"];
    [query findObjectsInBackgroundWithBlock:^(NSArray* objects, NSError* error) {
        // do something with the objects

    }];
}

And now for you Android fans:



void someMagicalFunction() {
    ParseQuery query = new ParseQuery("SomeClass");
    query.whereEqualTo("SomeProperty", "MagicString"
    query.findInBackground(new FindCallback() {
        public void done(List< ParseObject >objects, ParseException e) {
        // do something with objects
    });
}

Yup, that’s it. It really is that simple. If you want to know more take a look at the Parse docs. For those of you that are critical of Parse, I will be doing more than just code samples with it; in fact I have found a few deficiencies that I will be discussing in a future blog post.

More from Mike:

About Me

Hi! I’m Mike! I’m a software engineer who codes at The Mad Botter INC. You might know me from Coder Radio or The Mike Dominick Show.  Drop me a line if you’re interested in having some custom mobile or web development done.

Follow Me

© 2024 Copyright Michael Dominick | All rights reserved