-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#189
- Loading branch information
FlavioLionelRita
committed
Nov 17, 2023
1 parent
756eb82
commit 7c52331
Showing
9 changed files
with
31,125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "northwind", | ||
"type": "node", | ||
"request": "launch", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"program": "${workspaceFolder}/build/dev/labs/northwind/client/lab.js", | ||
"envFile": "${workspaceFolder}/config/collections/workspace/.env" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
# Northwind lab | ||
|
||
## Start | ||
|
||
```sh | ||
docker-compose -p lambdaorm-svc up -d | ||
mysql -h 0.0.0.0 -P 3306 -u northwind -pnorthwind northwind < northwind-mysql.sql | ||
``` | ||
|
||
## Test | ||
|
||
**Model:** | ||
|
||
```sh | ||
curl -X POST "http://localhost:9291/model?format=beautiful" -H "Content-Type: application/json" -d '{"expression": "Orders.filter(p=>p.id==id).include(p=>p.details)"}' | ||
``` | ||
|
||
Result: | ||
|
||
```json | ||
[ | ||
{ | ||
"name": "id", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "customerId", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "employeeId", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "orderDate", | ||
"type": "dateTime" | ||
}, | ||
{ | ||
"name": "requiredDate", | ||
"type": "date" | ||
}, | ||
{ | ||
"name": "shippedDate", | ||
"type": "date" | ||
}, | ||
{ | ||
"name": "shipViaId", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "freight", | ||
"type": "decimal" | ||
}, | ||
{ | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "address", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "city", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "region", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "postalCode", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "country", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "details", | ||
"type": "Orders.details[]", | ||
"children": [ | ||
{ | ||
"name": "orderId", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "productId", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "unitPrice", | ||
"type": "decimal" | ||
}, | ||
{ | ||
"name": "quantity", | ||
"type": "decimal" | ||
}, | ||
{ | ||
"name": "discount", | ||
"type": "decimal" | ||
}, | ||
{ | ||
"name": "LambdaOrmParentId", | ||
"type": "integer" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
**Parameters:** | ||
|
||
```sh | ||
curl -X POST "http://localhost:9291/parameters?format=beautiful" -H "Content-Type: application/json" -d '{"expression": "Orders.filter(p=>p.id==id).include(p=>p.details)"}' | ||
``` | ||
|
||
Result: | ||
|
||
```json | ||
[ | ||
{ | ||
"name": "id", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "details", | ||
"type": "Orders.details", | ||
"children": [ | ||
{ | ||
"name": "LambdaOrmParentId", | ||
"type": "any" | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
**Constraints:** | ||
|
||
```sh | ||
curl -X POST "http://localhost:9291/constraints?format=beautiful" -H "Content-Type: application/json" -d '{"expression": "Orders.filter(p=>p.id==id).include(p=>p.details)"}' | ||
``` | ||
|
||
Result: | ||
|
||
```json | ||
{ | ||
"entity": "Orders", | ||
"constraints": [], | ||
"children": [ | ||
{ | ||
"entity": "Orders.details", | ||
"constraints": [] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
**Sentence:** | ||
|
||
```sh | ||
curl -X POST "http://localhost:9291/sentence?format=beautiful" -H "Content-Type: application/json" -d '{"expression": "Orders.filter(p=>p.id==id).include(p=>p.details)"}' | ||
``` | ||
|
||
Result: | ||
|
||
```json | ||
{ | ||
"entity": "Orders", | ||
"dialect": "MySQL", | ||
"source": "default", | ||
"sentence": "SELECT o.OrderID AS id, o.CustomerID AS customerId, o.EmployeeID AS employeeId, o.OrderDate AS orderDate, o.RequiredDate AS requiredDate, o.ShippedDate AS shippedDate, o.ShipVia AS shipViaId, o.Freight AS freight, o.ShipName AS name, o.ShipAddress AS address, o.ShipCity AS city, o.ShipRegion AS region, o.ShipPostalCode AS postalCode, o.ShipCountry AS country, o.OrderID AS `__id` FROM Orders o WHERE o.OrderID = ? ", | ||
"children": [ | ||
{ | ||
"entity": "Orders.details", | ||
"dialect": "MySQL", | ||
"source": "default", | ||
"sentence": "SELECT o1.OrderID AS orderId, o1.ProductID AS productId, o1.UnitPrice AS unitPrice, o1.Quantity AS quantity, o1.Discount AS discount, o1.OrderID AS LambdaOrmParentId FROM `Order Details` o1 WHERE o1.OrderID IN (?) ", | ||
"children": [] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
**Execute:** | ||
|
||
```sh | ||
curl -X POST "http://localhost:9291/execute?format=beautiful" -H "Content-Type: application/json" -d '{"expression": "Orders.filter(p=>p.id==id).include(p=>p.details)", "data": "{\"id\": 10248}" }' | ||
``` | ||
|
||
Result: | ||
|
||
```json | ||
[ | ||
{ | ||
"id": 10248, | ||
"customerId": "VINET", | ||
"employeeId": 5, | ||
"orderDate": "1996-07-04T00:00:00.000Z", | ||
"requiredDate": "1996-08-01T00:00:00.000Z", | ||
"shippedDate": "1996-07-16T00:00:00.000Z", | ||
"shipViaId": 3, | ||
"freight": 32.38, | ||
"name": "Vins et alcools Chevalier", | ||
"address": "59 rue de l-Abbaye", | ||
"city": "Reims", | ||
"region": null, | ||
"postalCode": "51100", | ||
"country": "France", | ||
"details": [ | ||
{ | ||
"orderId": 10248, | ||
"productId": 11, | ||
"unitPrice": 14, | ||
"quantity": 12, | ||
"discount": 0 | ||
}, | ||
{ | ||
"orderId": 10248, | ||
"productId": 42, | ||
"unitPrice": 9.8, | ||
"quantity": 10, | ||
"discount": 0 | ||
}, | ||
{ | ||
"orderId": 10248, | ||
"productId": 72, | ||
"unitPrice": 34.8, | ||
"quantity": 5, | ||
"discount": 0 | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
## End | ||
|
||
```sh | ||
docker-compose -p lambdaorm-svc down --remove-orphans | ||
docker volume rm lambdaorm-svc_mysql-data | ||
docker volume rm lambdaorm-svc_mysql-log | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
version: "3.2" | ||
networks: | ||
northwind: | ||
driver: bridge | ||
services: | ||
mysql: | ||
container_name: mysql | ||
image: mysql:5.7 | ||
restart: always | ||
environment: | ||
- MYSQL_DATABASE=northwind | ||
- MYSQL_USER=northwind | ||
- MYSQL_PASSWORD=northwind | ||
- MYSQL_ROOT_PASSWORD=northwind | ||
ports: | ||
- '3306:3306' | ||
expose: | ||
- 3306 | ||
networks: | ||
- northwind | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
- mysql-log:/var/log/mysql | ||
orm: | ||
depends_on: | ||
- mysql | ||
container_name: orm | ||
image: flaviorita/lambdaorm-svc:0.8.43 | ||
restart: always | ||
environment: | ||
HOST: http://0.0.0.0 | ||
PORT: 9291 | ||
REQUEST_BODY_SIZE: 100mb | ||
RATE_LIMIT_WINDOWS_MS: 60000 | ||
RATE_LIMIT_MAX: 1000 | ||
WORKSPACE: /workspace | ||
MYSQL_CNX: '{"host":"mysql","port":3306,"user":"northwind","password":"northwind","database":"northwind","multipleStatements": true ,"waitForConnections": true }' | ||
ports: | ||
- '9291:9291' | ||
expose: | ||
- 9291 | ||
networks: | ||
- northwind | ||
volumes: | ||
- ./workspace:/workspace | ||
volumes: | ||
mysql-data: | ||
mysql-log: |
Oops, something went wrong.