Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Parse/Internal/Query/State/PFMutableQueryState.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
///--------------------------------------

- (void)includeKey:(NSString *)key;
- (void)includeKeys:(NSArray<NSString *> *)keys;

///--------------------------------------
#pragma mark - Selected Keys
Expand Down
8 changes: 8 additions & 0 deletions Parse/Internal/Query/State/PFMutableQueryState.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ - (void)includeKey:(NSString *)key {
}
}

- (void)includeKeys:(NSArray<NSString *> *)keys {
if (!_includedKeys) {
_includedKeys = [NSMutableSet setWithArray:keys];
} else {
[_includedKeys addObjectsFromArray:keys];
}
}

///--------------------------------------
#pragma mark - Selected Keys
///--------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion Parse/PFQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a "`" to the docs for includeKey as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thank you!


This has an effect similar to a join. You can use dot notation to specify which fields in
the included object are also fetch.
Expand All @@ -94,6 +94,15 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_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<NSString *> *)keys;

/**
Make the query restrict the fields of the returned `PFObject`s to include only the provided keys.

Expand Down
6 changes: 6 additions & 0 deletions Parse/PFQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@ - (instancetype)includeKey:(NSString *)key {
return self;
}

- (instancetype)includeKeys:(NSArray<NSString *> *)keys {
[self checkIfCommandIsRunning];
[self.state includeKeys:keys];
return self;
}

///--------------------------------------
#pragma mark - Select
///--------------------------------------
Expand Down