diff --git a/Parse/Internal/Query/State/PFMutableQueryState.h b/Parse/Internal/Query/State/PFMutableQueryState.h index 8470540f8..8cae97feb 100644 --- a/Parse/Internal/Query/State/PFMutableQueryState.h +++ b/Parse/Internal/Query/State/PFMutableQueryState.h @@ -65,6 +65,7 @@ ///-------------------------------------- - (void)includeKey:(NSString *)key; +- (void)includeKeys:(NSArray *)keys; ///-------------------------------------- #pragma mark - Selected Keys diff --git a/Parse/Internal/Query/State/PFMutableQueryState.m b/Parse/Internal/Query/State/PFMutableQueryState.m index 3ac9be934..901641b2b 100644 --- a/Parse/Internal/Query/State/PFMutableQueryState.m +++ b/Parse/Internal/Query/State/PFMutableQueryState.m @@ -151,6 +151,14 @@ - (void)includeKey:(NSString *)key { } } +- (void)includeKeys:(NSArray *)keys { + if (!_includedKeys) { + _includedKeys = [NSMutableSet setWithArray:keys]; + } else { + [_includedKeys addObjectsFromArray:keys]; + } +} + ///-------------------------------------- #pragma mark - Selected Keys ///-------------------------------------- diff --git a/Parse/PFQuery.h b/Parse/PFQuery.h index 323f37e85..d28137c40 100644 --- a/Parse/PFQuery.h +++ b/Parse/PFQuery.h @@ -83,7 +83,7 @@ typedef void (^PFQueryArrayResultBlock)(NSArray *_Nullable obje ///-------------------------------------- /** - Make the query include PFObjects that have a reference stored at the provided key. + Make the query include `PFObject`s that have a reference stored at the provided key. This has an effect similar to a join. You can use dot notation to specify which fields in the included object are also fetch. @@ -94,6 +94,15 @@ typedef void (^PFQueryArrayResultBlock)(NSArray *_Nullable obje */ - (instancetype)includeKey:(NSString *)key; +/** + Make the query include `PFObject`s that have a reference stored at the provided keys. + + @param keys The keys to load child `PFObject`s for. + + @return The same instance of `PFQuery` as the receiver. This allows method chaining. + */ +- (instancetype)includeKeys:(NSArray *)keys; + /** Make the query restrict the fields of the returned `PFObject`s to include only the provided keys. diff --git a/Parse/PFQuery.m b/Parse/PFQuery.m index 6767efa2a..7de3e7a8c 100644 --- a/Parse/PFQuery.m +++ b/Parse/PFQuery.m @@ -405,6 +405,12 @@ - (instancetype)includeKey:(NSString *)key { return self; } +- (instancetype)includeKeys:(NSArray *)keys { + [self checkIfCommandIsRunning]; + [self.state includeKeys:keys]; + return self; +} + ///-------------------------------------- #pragma mark - Select ///--------------------------------------