I often need to update a table using values from a different table and most of the time the quickest and also dirtiest solution is simply to do a subquery. A better and cleaner solution is to use the UPDATE .. SET .. FROM:

PostgreSQL logo

Let’s describe our case with an example:

I have a table journey_pattern in which I need to update the name based on the name of its line. I can find the line by joining 2 other tables: routes and lines.

Using a subquery I can simply do:

But what if lines.name is empty or null…


It’s a common task in my current position to download and restore client schema on my local postgres to debug it. So I decided to build a small CLI tool to help me.

Fully inspired (to not say copy/pasted) from this post by Lukas White
and James Hibbard:
Build a JavaScript Command Line Interface (CLI) with Node.js

How it works

I type pg-schema-restorer in my terminal and the following appears:

The tool look for the .backup files in my folders and subfolders of~/Documents and ~/Downloads and ask me to select one.

Once chosen it asks me the name of the schema (try to…


So you just finished your super webapp/api and it’s already going live. I’ll show you a simple way to add a basic monitoring on your server without adding a new dedicated app to do the task, using only your CI/CD

The scripts

Say you want to check if your app responds with an HTTP 200. The following command will exit with error if so:

curl — silent — show-error — fail https://my-webapp.fr/

If you want to verify that a specific endpoint respond with a json object containing a predefined number of elements. We’re using jq:

#/bin/shnbElements=$(curl https://my-webapp.fr/api/endpoint | jq length)
echo $nbElements
if…

A common problem when testing APIs is to be able to inject Mock of the services we don’t want to invoke during our test.

Imagine you’re testing an API that sends Email through the Postal Api.

The service postalServicethat will be sending the email should be tested on its own already, it’s not the goal of our API Test to verify that mails are correctly sent.

We would then want to mock the behavior of our service during the execution of the test with the behavior we will indicate in our mock. For instance we want to test that our…


A known limitation of the Postman Collection Runner is that it can only execute collection in a consecutive way. This is just a simple implementation of the solution explained in this StackOverflow conversation.

Create your Postman Collection and corresponding tests

Here I needed to attack first /api/persons to get the list of persons ids.

Postman query with a treatment of the resulted data into variable environment

And then /api/persons/:id for each person in the list.


Example of a Jersey project using the dependency injection framework HK2 to inject logged user into the application via a custum annotation

Jersey is a Java Framework that is commonly used to help generate REST Api.
HK2 is a lightweight framework which allow Inversion of Control (IoC) and dependency injection (DI)

Step 1: Starting a new Jersey Project

Generate a project from Maven Archetype:

mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
-DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example \
-DarchetypeVersion=2.29.1

Step 2: Business Logic

Add some business logic to make this test more interesting in com.example.business:

  • User
  • UserSvc
  • UserDao

Step 3: Automatically bind classes to their implementation

We want to be able to do Dependency Injection of our services. We need to register…


Le but de cet article est de vous montrer une solution simple et rapide pour mettre en place du déploiement continue.

La stack du projet est composée d’une partie API en nodejs et d’une base de donnée en mongodb. La pipeline va créer une nouvelle image de notre API en nodejs et la déployer sur notre registry privé.

1. Gitlab CI

L’objectif de notre pipeline est d’exécuter les tests unitaires et d’intégration puis de construire et déployer une image de l’API sur notre registry interne.

Dockerfile du container Node qui contient notre API

L’image du container Node est décrite ci dessus: on copie…


Les tests sont une composante primordiale de n’importe quel développement et il est aujourd’hui très commun de retrouver un grand nombre de tests unitaire et de tests d’intégration avec nos projets. Mais il est moins fréquent de retrouver des tests qui s’exécutent directement sur l’application déployée. Avec les outils dont nous disposons à ce jour il est désormais très simple de mettre en place une simple batterie de tests qui permettent de reproduire un scénario d’utilisation de nos APIs et surtout de les automatiser afin qu’ils fassent partie intégrante de la CI de vos projets.

1. Création de la collection de requêtes avec Postman

Commencez par créer une nouvelle…

m4nu56

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store