Get all fields from a DocumentDB joined query
Asked Answered
B

1

6

I have a DocumentDB database in Azure which I access through the CosmosDB API.

I'd like to get all the parent fields of a document with a simple query:

SELECT p.id 
    FROM parent p JOIN ch IN p.property1.child
    WHERE CONTAINS(UPPER(ch.name), UPPER(@childName))

This query works but I get only the 'id' property. I can't use p.* (a syntax error is throwed) and probably the list will change in the future. With * I get this error: 'SELECT *' is only valid with a single input set.

It's there a way to get the whole json of parent document without the need to write the complete list of fields on the select clause?

Benitobenjamen answered 16/1, 2018 at 8:44 Comment(0)
W
10

You can instead use SELECT VALUE p FROM p JOIN ch .... This is equivalent to p.*

Westfalen answered 16/1, 2018 at 16:24 Comment(1)
It works perfect. Only ... I get the same document several times :(. Any way to make a distinct in CosmosDB? Thanks.Benitobenjamen

© 2022 - 2024 — McMap. All rights reserved.