CouchbaseLite 3.0, Swift, Indexing array in where condition

Hello I have one question about indexing array in subquery, in where condition. Basicly I want just first element of array Array[0] in where condition.

"SELECT META().id FROM database 
WHERE ANY object in Objects[0] 
SATISFIES (object.isObject = false OR object.finalObject.isObject = false) END AND (Type = \'type\')"

There can be lot of Objects in array but i need just that first one.
Is that possible in couchbaselite 3.0 ?
Thanks for answers.

EDIT: I want replace WHERE ANY with WHERE FIRST. But I don’t know if its possible

@RomYk97 Does adding the clause “LIMIT 1” satisfy your need?

Hello, no I need all MainObjects which has array with another objects [Objects][0] and i need to compare just first element of this property. But MainObjects can be more than 1

Hi @RomYk97,

Do you have a real example? I don’t see where “Objects” comes from. META().id is a string. Could you please clarify? If you have a similar query that works in current version and suggest improvement in specific places, that would be greatly helpful.

Thanks,
Jianmin

Did you try that

SELECT META().id 
FROM database
WHERE (Objects[0].isObject = false OR Objects[0].finalObject.isObject = false) AND (Type = 'type')

@RomYk97, are you saying that query is not working when Objects[0] itself is an array? If so, I will file a bug, because the current grammar allows it.
With regard to your suggestion of WHERE FIRST, does @vsr1’s suggestion fit your need?

Hello, I did workaround through subObject oredrNumber but didnt find any solution through SQL/N1QL query.

Hi @RomYk97,

Sorry for not following up sooner. To clarify, regarding, “I want replace WHERE ANY with WHERE FIRST,” we currently do not have “WHERE FIRST,” as you wanted it. My question is, is it same as saying, Objects[0][0] ?

Cheers,
Jianmin