Lucas Reis
Lucas Reis

Reputation: 3

In couchbase, how can I select a value from array key?

I'm starting with Couchbase, because the feature of NoSQL and the implementation for the N1QL, similar as SQL syntax.

So, I'm trying to SELECT a value from array key, but there is no success... how can I filter these results?

enter image description here

SELECT players p FROM matches WHERE p. ???? = 'Aloh4'

Upvotes: 0

Views: 185

Answers (1)

vsr
vsr

Reputation: 7414

SELECT players FROM matches WHERE 'Aloh4' IN OBJECT_NAMES(players);

OR

CREATE INDEX ix1 ON matches( DISTINCT ARRAY pname FOR pname IN OBJECT_NAMES(players) END); SELECT players FROM matches WHERE ANY pname IN OBJECT_NAMES(players) SATISFIES pname = 'Aloh4' END;

Upvotes: 2

Related Questions