Reading data from DocumentDB

Let's query our data using SQL query structure:

  1. Click on the New SQL Query button and paste this query:
SELECT *  
FROM Families f  
WHERE f.id = "100" 
  1. This will yield the following result:
[{ 
  "id": "100", 
  "lastName": "Doe", 
  "parents": [ 
     { "firstName": "John" }, 
     { "firstName": "Mary"} 
  ], 
  "children": [ 
     { 
         "firstName": "Emily",  
         "gender": "female",  
         "grade": 5, 
         "pets": [{ "givenName": "Fluffy" }] 
     } 
  ], 
  "address": { "state": "WA", "county": "King", "city": "seattle" }, 
  "creationDate": 1431620472, 
  "isRegistered": true 
}] 
  1. You can also execute a traditional order by queries, similar to the following one:
SELECT c.givenName  
FROM Families f  
JOIN c IN f.children  
WHERE f.id = '200' 
ORDER BY f.address.city ASC
  1. This will yield the following result:
[ 
  { "givenName": "Jesse" },  
  { "givenName": "Lisa"} 
]
  1. You can also run the sub-queries, that is, get the subdocuments from the main document. You can refer to the following query:
SELECT *  
FROM Families.children 
  1. This will yield the following result:
[ 
  [ 
    { 
        "firstName": "Emily", 
        "gender": "female", 
        "grade": 5, 
        "pets": [ 
          { 
              "givenName": "Fluffy" 
          } 
        ] 
    } 
  ], 
  [ 
    { 
        "familyName": "Merriam", 
        "givenName": "Jesse", 
        "gender": "female", 
        "grade": 1 
    }, 
    { 
        "familyName": "Miller", 
        "givenName": "Lisa", 
        "gender": "female", 
        "grade": 8 
    } 
  ] 
] 

So, we now know how to create and query documents. Let's perform an UPDATE and DELETE operation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.88.165