Order by field from embedded object

Hello everyone! I have some some documents like this example:

{
    "creds": [
        {
            "type": 250300001,
            "val": "Test"
        },
        {
            "type": 250300002,
            "val": "TestNickname"
        }
    ],
    "deptId": 999,
    "fullName": "Test Test",
    "langIana": "ru"
}

How I can order documents by creds.val where creds.type = 250300001?
Thnx!

you can use UNNEST , for example

SELECT d.*
  FROM default d 
UNNEST d.creds c 
 WHERE c.type = 250300001
 ORDER BY c.val
1 Like