File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,24 @@ typedef NS_ENUM(NSUInteger, OrderBy) {
230230 */
231231
232232- (void )fetchAll : (void (^) (ResponseType type,NSArray <Asset *> * BUILT_NULLABLE_P result,NSError * BUILT_NULLABLE_P error))completionBlock ;
233+
234+ /* *
235+ This method fetches assets using other fields than UID..
236+
237+ //Obj-C
238+ [assetLib where:(NSString *)field equalTo:(NSObject *)value];
239+
240+ //Swift
241+ assetLib.where("fieldName","value");
242+
243+ This allows filtering assets by specifying the field name and the value to match.
244+ @param field The name of the field to filter by.
245+ @param value The value that the field should match.
246+ */
247+ - (void )where : (NSString *)field equalTo : (NSObject *)value ;
248+
249+ - (NSDictionary *)getPostParamDictionary ;
250+
233251@end
234252
235253BUILT_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -156,6 +156,25 @@ - (void)cancelRequest {
156156 [self .requestOperation cancel ];
157157 }
158158}
159+ // MARK: - Where Query -
160+ - (NSDictionary *) getPostParamDictionary {
161+ return [self .postParamDictionary copy ];
162+ }
163+
164+ - (void )where : (NSString *)field equalTo : (NSObject *)value {
165+ if (field.length == 0 || !value) {
166+ NSLog (@" Field or value cannot be empty" );
167+ return ;
168+ }
169+ NSMutableDictionary *queryDict = [NSMutableDictionary dictionary ];
170+ NSDictionary *existingQuery = self.postParamDictionary [@" query" ];
171+ // If an existing query exists, merge it
172+ if (existingQuery) {
173+ [queryDict addEntriesFromDictionary: existingQuery];
174+ }
175+ queryDict[field] = value;
176+ [self .postParamDictionary setObject: queryDict forKey: @" query" ];
177+ }
159178
160179
161180@end
You can’t perform that action at this time.
0 commit comments