Start a new topic

How to query an object in a collection?

If I have a column that is a JSON definition of an object, can I query on a specific item in that object? Ie, if I have a column named "Profile" that is represented by `{"FirstName": "John", "LastName": "Doe"}` is it possible to search for all profiles that have the LastName of "Doe"?

Thanks for the help Mike!
With objects in a field, you need to use dot notation to access it. In this case, The first name sub-field is `Profile.FirstName`, and last name would be `Profile.LastName`. You can then use exactMatchForValue `Doe` on that key path.
Read through that before I posted here, nothing specifically mentions querying an object/dictionary type. I've tried a variety of permutations with no success:

[query addQueryOnField:@"Profile" usingConditional:kKCSIn forValue:@"Doe"];

[KCSQuery queryOnField:@"Profile" withExactMatchForValue:{@"LastName": @"Doe"}];

[KCSQuery queryOnField:@"Profile" withExactMatchForValue:@"Doe"];

[query addQueryOnField:@"Profile" usingConditional:kKCSIn forValue:@{@"LastName": @"Doe"}];

[query addQueryOnField:@"Profile.LastName" usingConditional:kKCSIn forValue:@"Doe"];

I realize some of these don't even make sense but that's where I'm at right now - tried everything that seemed rational with no luck. Hopefully this clarifies what I'm trying to do and why I'm having issues.
Login or Signup to post a comment