Plan
Devuelve el plan de ejecución de una expresión de consulta: la sentencia que se ejecuta en cada fuente, sin ejecutarla.
Opciones
| Opción | Corta | Descripción |
|---|---|---|
| workspace | -w |
Ruta del proyecto (por defecto: el directorio actual). |
| stage | -s |
Nombre del stage (por defecto: el primer stage del esquema). |
| query | -q |
Expresión de consulta. |
| envfile | -e |
Lee un archivo de variables de entorno. |
| output | -o |
Formato de salida: json, beautiful, light o yaml. |
| url | -u |
URL del esquema en un Data Gateway, para ejecutar el comando allí. |
Ejemplo
lambdaorm plan -o beautiful -q "Orders.filter(p => p.customerId == customerId).include(p => [p.customer.map(p => p.name), p.details.include(p => p.product.include(p => p.category.map(p => p.name)).map(p => p.name)).map(p => [p.quantity, p.unitPrice])]).page(1,2)"
Resultado:
{
"entity": "Orders",
"dialect": "MongoDB",
"source": "Ordering",
"sentence": "[{ \"$match\" : { \"CustomerID\":{{customerId}} } }, { \"$project\" :{ \"_id\": 0 , \"id\":\"$_id\", \"customerId\":\"$CustomerID\", \"employeeId\":\"$EmployeeID\", \"orderDate\":\"$OrderDate\", \"requiredDate\":\"$RequiredDate\", \"shippedDate\":\"$ShippedDate\", \"shipViaId\":\"$ShipVia\", \"freight\":\"$Freight\", \"name\":\"$ShipName\", \"address\":\"$ShipAddress\", \"city\":\"$ShipCity\", \"region\":\"$ShipRegion\", \"postalCode\":\"$ShipPostalCode\", \"country\":\"$ShipCountry\", \"__customerId\":\"$CustomerID\", \"__id\":\"$_id\" ,\"details\": { \"$map\":{ \"input\": \"$\\\"Order Details\\\"\", \"in\": { \"quantity\":\"$$this.Quantity\", \"unitPrice\":\"$$this.UnitPrice\", \"__productId\":\"$$this.ProductID\", \"LambdaOrmParentId\":\"$$this.OrderID\" } }} }} , { \"$sort\" :{ \"_id\":1 } } , { \"$skip\" : 0 }, { \"$limit\" : 2 } , { \"$project\": { \"_id\": 0 } }]",
"children": [
{
"entity": "Customers",
"dialect": "PostgreSQL",
"source": "Crm",
"sentence": "SELECT c.CompanyName AS \"name\", c.CustomerID AS \"LambdaOrmParentId\" FROM Customers c WHERE c.CustomerID IN ($1) "
},
{
"entity": "Orders.details",
"dialect": "MongoDB",
"source": "Ordering",
"sentence": "[{ \"$unwind\" : \"$\\\"Order Details\\\"\" }, { \"$replaceRoot\": { \"newRoot\": \"$\\\"Order Details\\\"\" } }, { \"$match\" : { \"OrderID\":{ \"$in\" :[{{LambdaOrmParentId}}]} } }, { \"$project\" :{ \"_id\": 0 , \"quantity\":\"$Quantity\", \"unitPrice\":\"$UnitPrice\", \"__productId\":\"$ProductID\", \"LambdaOrmParentId\":\"$OrderID\" }} , { \"$project\": { \"_id\": 0 } }]",
"children": [
{
"entity": "Products",
"dialect": "MySQL",
"source": "Catalog",
"sentence": "SELECT p.ProductName AS name, p.CategoryID AS `__categoryId`, p.ProductID AS LambdaOrmParentId FROM Products p WHERE p.ProductID IN (?) ",
"children": [
{
"entity": "Categories",
"dialect": "MySQL",
"source": "Catalog",
"sentence": "SELECT c1.CategoryName AS name, c1.CategoryID AS LambdaOrmParentId FROM Categories c1 WHERE c1.CategoryID IN (?) "
}
]
}
]
}
]
}