在 RavenDB 4.0+ 中,对于给定的示例 Northwind 数据库(也可在http://live-test.ravenb.net/获得),RQL 查询可以用于:
- 进入
Orders
其中至少一个有Lines
?Discount == 0
- 得到的都在
Orders
哪?Lines
Discount != 0
- 进入
Orders
其中至少一个有Lines
?Discount != 0
- 得到的都在
Orders
哪?Lines
Discount == 0
这是一个示例文档结构:
{
"Company": "companies/85-A",
"Employee": "employees/5-A",
"Freight": 32.38,
"Lines": [
{
"Discount": 0,
"PricePerUnit": 14,
"Product": "products/11-A",
"ProductName": "Queso Cabrales",
"Quantity": 12
},
{
"Discount": 0,
"PricePerUnit": 9.8,
"Product": "products/42-A",
"ProductName": "Singaporean Hokkien Fried Mee",
"Quantity": 10
},
{
"Discount": 0,
"PricePerUnit": 34.8,
"Product": "products/72-A",
"ProductName": "Mozzarella di Giovanni",
"Quantity": 5
}
],
"OrderedAt": "1996-07-04T00:00:00.0000000",
"RequireAt": "1996-08-01T00:00:00.0000000",
"ShipTo": {
"City": "Reims",
"Country": "France",
"Line1": "59 rue de l'Abbaye",
"Line2": null,
"Location": {
"Latitude": 49.25595819999999,
"Longitude": 4.1547448
},
"PostalCode": "51100",
"Region": null
},
"ShipVia": "shippers/3-A",
"ShippedAt": "1996-07-16T00:00:00.0000000",
"@metadata": {
"@collection": "Orders",
"@flags": "HasRevisions",
"@id": "orders/1-A",
"@last-modified": "2018-07-27T12:11:53.0447651Z",
"@change-vector": "A:417-EKrWjfz5kESi6lp7Nf442Q",
"@index-score": 1
}
}
我设法只为 1 和 2 找到了一些答案:
- 进入
Orders
其中至少一个有Lines
?Discount == 0
from Orders where Lines[].Discount == 0
from Orders where Lines[].Discount IN (0)
from Orders where Lines[].Discount ALL IN (0)
- 得到的都在
Orders
哪?Lines
Discount != 0
from Orders where Lines[].Discount != 0