postgreSQL and middleware