DocumentDB find deep key:value

2019-09-01 15:05发布

in MongoDB I can perform a find on any deep level key like

collection.find('persons.age': 12)

Is a similar thing possible with document DB? I have tried something like the following which fails with: code":"BadRequest" - could not be resolved.

query: "SELECT * FROM root WHERE person.age = 12"

1条回答
甜甜的少女心
2楼-- · 2019-09-01 15:55

You must reference the collection from the FROM clause.

Note: Since you are issuing queries directly to a collection, you can use any arbitrary value for the name. However, you must re-use whatever value you chose in the other clauses because it serves as a reference point for projections and predicates (in the SELECT and WHERE clause).

If your document's schema resembles:

{
    person: {
        age: 39
    }
}

You can query documents by age using:

SELECT *
FROM root
WHERE root.person.age = 39

Or if your document's schema resembles:

{
    age: 39
}

You can query documents by age using:

SELECT *
FROM person
WHERE person.age = 39
查看更多
登录 后发表回答