mirror of https://github.com/dapr/docs.git
state store query API: remove 'value' prefix from key names (#2195)
Signed-off-by: Dmitry Shmulevich <dmitry.shmulevich@gmail.com>
This commit is contained in:
parent
af2d1d0a3f
commit
d2503bc73d
|
@ -32,7 +32,7 @@ You can find additional information in the [related links]({{< ref "#related-lin
|
||||||
You submit query requests via HTTP POST/PUT or gRPC.
|
You submit query requests via HTTP POST/PUT or gRPC.
|
||||||
The body of the request is the JSON map with 3 entries: `filter`, `sort`, and `page`.
|
The body of the request is the JSON map with 3 entries: `filter`, `sort`, and `page`.
|
||||||
|
|
||||||
The `filter` is an optional section. It specifies the query conditions in the form of a tree of key/value operations, where the key is the operator and the value is the operands.
|
The `filter` is an optional section. It specifies the query conditions in the form of a tree, where each node represents either unary or multi-operand operation.
|
||||||
|
|
||||||
The following operations are supported:
|
The following operations are supported:
|
||||||
|
|
||||||
|
@ -43,6 +43,24 @@ The following operations are supported:
|
||||||
| `AND` | []operation | operation[0] AND operation[1] AND ... AND operation[n] |
|
| `AND` | []operation | operation[0] AND operation[1] AND ... AND operation[n] |
|
||||||
| `OR` | []operation | operation[0] OR operation[1] OR ... OR operation[n] |
|
| `OR` | []operation | operation[0] OR operation[1] OR ... OR operation[n] |
|
||||||
|
|
||||||
|
The `key` in the operand is similar to the JSONPath notation. Each dot in the key indicates a nested JSON structure. Consider for example this structure:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"shape": {
|
||||||
|
"name": "rectangle",
|
||||||
|
"dimensions": {
|
||||||
|
"height": 24,
|
||||||
|
"width": 10
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"name": "red",
|
||||||
|
"code": "#FF0000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
If you want to compare the value of the color code, the key will be `shape.color.code`
|
||||||
|
|
||||||
If `filter` section is omitted, the query returns all entries.
|
If `filter` section is omitted, the query returns all entries.
|
||||||
|
|
||||||
The `sort` is an optional section and is an ordered array of `key:order` pairs, where `key` is a key in the state store, and the `order` is an optional string indicating sorting order: `"ASC"` for ascending and `"DESC"` for descending. If omitted, ascending order is the default.
|
The `sort` is an optional section and is an ordered array of `key:order` pairs, where `key` is a key in the state store, and the `order` is an optional string indicating sorting order: `"ASC"` for ascending and `"DESC"` for descending. If omitted, ascending order is the default.
|
||||||
|
@ -93,11 +111,11 @@ This is the [query](../query-api-examples/query1.json):
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"filter": {
|
"filter": {
|
||||||
"EQ": { "value.state": "CA" }
|
"EQ": { "state": "CA" }
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.person.id",
|
"key": "person.id",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -107,9 +125,9 @@ This is the [query](../query-api-examples/query1.json):
|
||||||
An equivalent of this query in SQL is:
|
An equivalent of this query in SQL is:
|
||||||
```sql
|
```sql
|
||||||
SELECT * FROM c WHERE
|
SELECT * FROM c WHERE
|
||||||
value.state = "CA"
|
state = "CA"
|
||||||
ORDER BY
|
ORDER BY
|
||||||
value.person.id DESC
|
person.id DESC
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the query with the following command:
|
Execute the query with the following command:
|
||||||
|
@ -190,7 +208,7 @@ This is the [query](../query-api-examples/query2.json):
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"filter": {
|
"filter": {
|
||||||
"IN": { "value.person.org": [ "Dev Ops", "Hardware" ] }
|
"IN": { "person.org": [ "Dev Ops", "Hardware" ] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -198,7 +216,7 @@ This is the [query](../query-api-examples/query2.json):
|
||||||
An equivalent of this query in SQL is:
|
An equivalent of this query in SQL is:
|
||||||
```sql
|
```sql
|
||||||
SELECT * FROM c WHERE
|
SELECT * FROM c WHERE
|
||||||
value.person.org IN ("Dev Ops", "Hardware")
|
person.org IN ("Dev Ops", "Hardware")
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the query with the following command:
|
Execute the query with the following command:
|
||||||
|
@ -232,15 +250,15 @@ This is the [query](../query-api-examples/query3.json):
|
||||||
"filter": {
|
"filter": {
|
||||||
"OR": [
|
"OR": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Dev Ops" }
|
"EQ": { "person.org": "Dev Ops" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Finance" }
|
"EQ": { "person.org": "Finance" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IN": { "value.state": [ "CA", "WA" ] }
|
"IN": { "state": [ "CA", "WA" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -248,11 +266,11 @@ This is the [query](../query-api-examples/query3.json):
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.state",
|
"key": "state",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "value.person.id"
|
"key": "person.id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"page": {
|
"page": {
|
||||||
|
@ -264,11 +282,11 @@ This is the [query](../query-api-examples/query3.json):
|
||||||
An equivalent of this query in SQL is:
|
An equivalent of this query in SQL is:
|
||||||
```sql
|
```sql
|
||||||
SELECT * FROM c WHERE
|
SELECT * FROM c WHERE
|
||||||
value.person.org = "Dev Ops" OR
|
person.org = "Dev Ops" OR
|
||||||
(value.person.org = "Finance" AND value.state IN ("CA", "WA"))
|
(person.org = "Finance" AND state IN ("CA", "WA"))
|
||||||
ORDER BY
|
ORDER BY
|
||||||
value.state DESC,
|
state DESC,
|
||||||
value.person.id ASC
|
person.id ASC
|
||||||
LIMIT 3
|
LIMIT 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -338,15 +356,15 @@ The pagination token is used "as is" in the [subsequent query](../query-api-exam
|
||||||
"filter": {
|
"filter": {
|
||||||
"OR": [
|
"OR": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Dev Ops" }
|
"EQ": { "person.org": "Dev Ops" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Finance" }
|
"EQ": { "person.org": "Finance" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IN": { "value.state": [ "CA", "WA" ] }
|
"IN": { "state": [ "CA", "WA" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -354,11 +372,11 @@ The pagination token is used "as is" in the [subsequent query](../query-api-exam
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.state",
|
"key": "state",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "value.person.id"
|
"key": "person.id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"page": {
|
"page": {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"filter": {
|
"filter": {
|
||||||
"EQ": { "value.state": "CA" }
|
"EQ": { "state": "CA" }
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.person.id",
|
"key": "person.id",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"filter": {
|
"filter": {
|
||||||
"IN": { "value.person.org": [ "Dev Ops", "Hardware" ] }
|
"IN": { "person.org": [ "Dev Ops", "Hardware" ] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
"filter": {
|
"filter": {
|
||||||
"OR": [
|
"OR": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Dev Ops" }
|
"EQ": { "person.org": "Dev Ops" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Finance" }
|
"EQ": { "person.org": "Finance" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IN": { "value.state": [ "CA", "WA" ] }
|
"IN": { "state": [ "CA", "WA" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.state",
|
"key": "state",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "value.person.id"
|
"key": "person.id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"page": {
|
"page": {
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
"filter": {
|
"filter": {
|
||||||
"OR": [
|
"OR": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Dev Ops" }
|
"EQ": { "person.org": "Dev Ops" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Finance" }
|
"EQ": { "person.org": "Finance" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IN": { "value.state": [ "CA", "WA" ] }
|
"IN": { "state": [ "CA", "WA" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,11 @@
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.state",
|
"key": "state",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "value.person.id"
|
"key": "person.id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"page": {
|
"page": {
|
||||||
|
|
|
@ -336,15 +336,15 @@ curl http://localhost:3500/v1.0-alpha1/state/myStore/query \
|
||||||
"filter": {
|
"filter": {
|
||||||
"OR": [
|
"OR": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Dev Ops" }
|
"EQ": { "person.org": "Dev Ops" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
"EQ": { "value.person.org": "Finance" }
|
"EQ": { "person.org": "Finance" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"IN": { "value.state": [ "CA", "WA" ] }
|
"IN": { "state": [ "CA", "WA" ] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -352,11 +352,11 @@ curl http://localhost:3500/v1.0-alpha1/state/myStore/query \
|
||||||
},
|
},
|
||||||
"sort": [
|
"sort": [
|
||||||
{
|
{
|
||||||
"key": "value.state",
|
"key": "state",
|
||||||
"order": "DESC"
|
"order": "DESC"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "value.person.id"
|
"key": "person.id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"page": {
|
"page": {
|
||||||
|
|
Loading…
Reference in New Issue