Skip to content

Commit eab68c5

Browse files
committed
README updated
1 parent 7619738 commit eab68c5

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,41 @@ This project is using:
4848

4949
> No manual Postgres database installation is required.
5050
51-
## Test it / Run it
51+
## Test it
5252
Run tests:
5353

5454
```shell
5555
cargo pgrx test
5656
```
5757

58-
Compile/install extension to a pgrx-managed Postgres instance and start psql:
58+
## Run it
59+
Compile/install extension to a pgrx-managed Postgres instance and start psql console:
5960
```shell
6061
cargo pgrx run
6162
```
6263

64+
Now, you can run the following SQL commands in the psql console:
65+
66+
1. Load the extension:
67+
```sql
68+
create extension fmodel_rust_postgres;
69+
```
70+
71+
2. Send commands to the system:
72+
73+
> Observe how the Commands are formatted in JSON format.
74+
75+
Create a restaurant:
76+
```sql
77+
select handle('{"type": "CreateRestaurant","identifier": "e48d4d9e-403e-453f-b1ba-328e0ce23737", "name": "Joe", "menu": {"menu_id": "02f09a3f-1624-3b1d-8409-44eff7708210", "items": [{"id": "02f09a3f-1624-3b1d-8409-44eff7708210","name": "supa","price": 10},{"id": "02f09a3f-1624-3b1d-8409-44eff7708210","name": "sarma","price": 20 }],"cuisine": "Vietnamese"}}'::Command);
78+
```
79+
80+
Place an order at the restaurant:
81+
```sql
82+
select handle('{"type": "PlaceOrder","identifier": "e48d4d9e-403e-453f-b1ba-328e0ce23737", "order_identifier": "afd909c6-f8f3-49b2-af7f-833e933cbab4", "line_items": [{"id": "02f09a3f-1624-3b1d-8409-44eff7708210","quantity": 1, "menu_item_id": "02f09a3f-1624-3b1d-8409-44eff7708210", "name": "supa", "price": 10},{"id": "02f09a3f-1624-3b1d-8409-44eff7708210", "quantity": 1, "menu_item_id": "02f09a3f-1624-3b1d-8409-44eff7708210","name": "sarma","price": 20 }]}'::Command);
83+
```
84+
85+
6386
Confused? Run `cargo pgrx help`
6487

6588
## The structure of the project

0 commit comments

Comments
 (0)