Skip to content

Commit a4eb075

Browse files
committed
Merge pull request #765 from AndrewSB/patch-1
add includeKeys convenience to PFQuery
2 parents f3522cf + 72b18ff commit a4eb075

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Parse/Internal/Query/State/PFMutableQueryState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
///--------------------------------------
6666

6767
- (void)includeKey:(NSString *)key;
68+
- (void)includeKeys:(NSArray<NSString *> *)keys;
6869

6970
///--------------------------------------
7071
#pragma mark - Selected Keys

Parse/Internal/Query/State/PFMutableQueryState.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ - (void)includeKey:(NSString *)key {
151151
}
152152
}
153153

154+
- (void)includeKeys:(NSArray<NSString *> *)keys {
155+
if (!_includedKeys) {
156+
_includedKeys = [NSMutableSet setWithArray:keys];
157+
} else {
158+
[_includedKeys addObjectsFromArray:keys];
159+
}
160+
}
161+
154162
///--------------------------------------
155163
#pragma mark - Selected Keys
156164
///--------------------------------------

Parse/PFQuery.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_Nullable obje
8383
///--------------------------------------
8484

8585
/**
86-
Make the query include PFObjects that have a reference stored at the provided key.
86+
Make the query include `PFObject`s that have a reference stored at the provided key.
8787
8888
This has an effect similar to a join. You can use dot notation to specify which fields in
8989
the included object are also fetch.
@@ -94,6 +94,15 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_Nullable obje
9494
*/
9595
- (instancetype)includeKey:(NSString *)key;
9696

97+
/**
98+
Make the query include `PFObject`s that have a reference stored at the provided keys.
99+
100+
@param keys The keys to load child `PFObject`s for.
101+
102+
@return The same instance of `PFQuery` as the receiver. This allows method chaining.
103+
*/
104+
- (instancetype)includeKeys:(NSArray<NSString *> *)keys;
105+
97106
/**
98107
Make the query restrict the fields of the returned `PFObject`s to include only the provided keys.
99108

Parse/PFQuery.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ - (instancetype)includeKey:(NSString *)key {
405405
return self;
406406
}
407407

408+
- (instancetype)includeKeys:(NSArray<NSString *> *)keys {
409+
[self checkIfCommandIsRunning];
410+
[self.state includeKeys:keys];
411+
return self;
412+
}
413+
408414
///--------------------------------------
409415
#pragma mark - Select
410416
///--------------------------------------

0 commit comments

Comments
 (0)