We are pleased to announce release of Injee 0.3.0. In this release, we have added ability to add and remove columns from tables. To get it execute:
$ curl -L https://yu7.in/run-injee | sh
Once the server is running, let’s add some users:
$ curl -X POST http://localhost:4125/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Saravanan"}'
$ curl -X POST http://localhost:4125/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Karthikeyan"}'
$ curl -X POST http://localhost:4125/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Aravindan", "country": "Sri Lanka"}'
Now let’s list all users:
$ curl http://localhost:4125/api/users
We get the following output:
[
{
"name": "Saravanan",
"created_at": "2024-08-19T15:23:54Z",
"updated_at": "2024-08-19T15:23:54Z",
"id": "902b155f-3bd5-4309-bfe4-104c49c51fe2"
},
{
"name": "Karthikeyan",
"created_at": "2024-08-19T15:24:09Z",
"updated_at": "2024-08-19T15:24:09Z",
"id": "46f917dd-99c2-45ca-bed2-2906afee16f8"
},
{
"name": "Aravindan",
"country": "Sri Lanka",
"created_at": "2024-08-19T15:24:18Z",
"updated_at": "2024-08-19T15:24:18Z",
"id": "e9b3cd95-861e-414e-9417-c6267b51c222"
}
]
You see that only Aravindan has a country, and others do not. Now let’s add country
column to users
and default it to India.
$ curl -X POST http://localhost:4125/ops/add-column/users/country \
-H "Content-Type: application/json" \
-d '{"default": "India"}'
{
"message": "added column country to table users"
}
We get a message saying that the column has been added. Now let’s list users again:
$ curl http://localhost:4125/api/users
[
{
"name": "Saravanan",
"created_at": "2024-08-19T15:23:54Z",
"updated_at": "2024-08-19T15:23:54Z",
"country": "India",
"updated_at": "2024-08-19T15:27:09Z",
"id": "902b155f-3bd5-4309-bfe4-104c49c51fe2"
},
{
"name": "Karthikeyan",
"created_at": "2024-08-19T15:24:09Z",
"updated_at": "2024-08-19T15:24:09Z",
"country": "India",
"updated_at": "2024-08-19T15:27:09Z",
"id": "46f917dd-99c2-45ca-bed2-2906afee16f8"
},
{
"name": "Aravindan",
"country": "Sri Lanka",
"created_at": "2024-08-19T15:24:18Z",
"updated_at": "2024-08-19T15:24:18Z",
"id": "e9b3cd95-861e-414e-9417-c6267b51c222"
}
]
You see that country of Aravindan remains untouched, and it’s still Sri Lanka, but for Saravanan and Karthikeyan, country is India, these values have been newly added.
Now let’s remove the country column:
$ curl -X DELETE http://localhost:4125/ops/remove-column/users/country
We get message as shown below that says country column is removed:
{
"message": "removed column country from table users"
}
Now let’s list users
$ curl http://localhost:4125/api/users
Now country column is gone as you see below.
[
{
"name": "Saravanan",
"created_at": "2024-08-19T15:23:54Z",
"updated_at": "2024-08-19T15:23:54Z",
"updated_at": "2024-08-19T15:27:09Z",
"id": "902b155f-3bd5-4309-bfe4-104c49c51fe2"
},
{
"name": "Karthikeyan",
"created_at": "2024-08-19T15:24:09Z",
"updated_at": "2024-08-19T15:24:09Z",
"updated_at": "2024-08-19T15:27:09Z",
"id": "46f917dd-99c2-45ca-bed2-2906afee16f8"
},
{
"name": "Aravindan",
"created_at": "2024-08-19T15:24:18Z",
"updated_at": "2024-08-19T15:24:18Z",
"id": "e9b3cd95-861e-414e-9417-c6267b51c222"
}
]
In the terminal, where injee is running, you may press Ctrl+C
to exit.