I have the following documents:
{
"_id": “ecc:102”,
“type”: “category”,
“items”: [
“eci:742”,
“eci:743”,
“eci:744”,
],
“name”: “Skills”
},
{
"_id": “eci:742”,
“type”: “item”,
“chinese”: “技术”,
“english”: “technique”,
“pinyin”: “jìshù”
},
{
"_id": “eci:743”,
“type”: “item”,
“chinese”: “技巧”,
“english”: “skill”,
“pinyin”: “jìqiǎo”
},
{
"_id": “eci:744”,
“type”: “item”,
“chinese”: “技能”,
“english”: “ability”,
“pinyin”: “jìnéng”
}
I want to run the following query using the CBL 2.0 Objective C library:
SELECT item.*
FROM rememberit
category
JOIN rememberit
item ON KEYS category.items
WHERE META(category).id = ‘ecc:102’
I’ve run it in the query editor and it works fine but I can’t see how to implement the ON KEYS using the API.
Here’s what I’ve got so far:
CBLQueryExpression *on = [[CBLQueryMeta idFrom:@"item"] in:[CBLQueryExpression property:@"items" from:@"category"]];
CBLQueryJoin *join = [CBLQueryJoin join:[CBLQueryDataSource database:database as:@"item"]
on: on];
CBLQuery* query = [CBLQuery select:@[[CBLQuerySelectResult allFrom:@"item" ]]
from:[CBLQueryDataSource database:database as:@"category"]
join: join
where:[[CBLQueryMeta idFrom:@"category"] equalTo:categoryId]];
This gives me an error on trying to create the on expression:
[CBLPropertyExpression countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7f8d98d4bd80
I’ve also tried:
CBLQueryExpression *on = [CBLQueryArrayFunction contains:[CBLQueryExpression property:@"items" from:@"category"] value:[CBLQueryMeta idFrom:@"item"]];
But that didn’t work either.