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?

Alpha75
  • 2,140
  • 1
  • 26
  • 49

1 Answers1

9

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

Aravind Krishna R.
  • 7,885
  • 27
  • 37
  • It works perfect. Only ... I get the same document several times :(. Any way to make a distinct in CosmosDB? Thanks. – Alpha75 Jan 17 '18 at 12:28