Vert.x 3 and PostgreSQL JSON type

One of the in­ter­est­ing fea­tures of NoSQL data­bases is their schema-​less mode of op­er­a­tion. This fea­ture is very use­ful dur­ing project pro­to­typ­ing and early de­vel­op­ment since at early the stages of de­vel­op­ment of projects all data struc­tures are not clear or have been de­fined yet. The rea­son of this post is not to dis­cuss about that sub­ject, but to show that some­times you can also use NoSQL with a more tra­di­tional data­base en­gine like Post­greSQL.

Since ver­sion 9.3 there is sup­port for JSON how­ever with ver­sion 9.4 there is even bet­ter sup­port with the new type JSONB. I will now show how to use the basic JSON type in a sim­ple REST ap­pli­ca­tion writ­ten with Vert.x3:

...waiting for Gist...

Now all you need to do is play with this REST ser­vice, for this you can use curl to cre­ate a sale:

$ curl \
    -i \
    -H "Content-Type: application/json" \
    -X POST \
    -d '{"id": 1, "customer_name": "John", "items": {"description": "milk", "quantity": 4}}' \
    http://localhost:8080/sales

HTTP/1.1 201 Created
Content-Length: 0

And if you want to read that new doc­u­ment:

$ curl -i -H "Accept: application/json" -X GET http://localhost:8080/sales/1
HTTP/1.1 200 OK
content-type: application/json
Content-Length: 75

{"id":1,"customer_name":"John","items":{"description":"milk","quantity":4}}
Next post

Checklist for Migrating from Vert.x 2.1.x to Vert.x 3 - Part One

So while upgrading our application, I thought I should note down all the changes that we had to do in the process. Since Vert.x 3 is a major upgrade from the previous version, with so many changes.

Read more
Previous post

Vert.x 3 init.d Script

Let's say you have a Vert.x 3 application you want to install on a Linux server. But you want the old school way (I mean not the Docker way).

Read more
Related posts

Eclipse Vert.x meets GraphQL

In this blog post, we will look at an example application written in Vert.x that uses the new GraphQL API of Gentics Mesh.

Read more

Eclipse Vert.x 4 milestone 5 released!

We are extremely pleased to announce the fifth 4.0 milestone release of Eclipse Vert.x. This release aims to provide a reliable distribution of the current development of Vert.x 4.

Read more

Eclipse Vert.x 3.7.0 released!

We are extremely pleased to announce that the Eclipse Vert.x version 3.7.0 has been released.

Read more