The Wonderful and Dangerous to_json from Postgres

The Wonderful and Dangerous to_json from Postgres

PostgreSQL is an amazing RDBMS. Not only is has it been ACID compliant since 2001, it supports many data types and functions, putting it on par with Document Store systems like MongoDB. Postgres supports a wide range of JSON formats and methods to store, search, and transform JSON object data. For instance, the to_json and related function json_agg allow you to collect a row into a JSON object. Handy for when you have nested data and want PG to return an object with nested values.

Amazon S3 Browser upload

Amazon S3 Browser upload

It’s 2018 and file upload is still an involved process

I’ll admit, this process is not straight forward, but once set up, it works like a charm. What’s the goal? We want the client (browser) to upload a file directly to S3 and then store the uploaded information in our server/database.

Cool Tips When Using Knex with Postgres

Cool Tips When Using Knex with Postgres

I’ve been using Knex for a long time, closing in on two years. Just to clarify, Knex is NOT an ORM (Object Relation Model). ORM’s try to model your database into neat and logic classes, but I agree with Laurie Voss, and ORM is an anti-pattern. I’ve used Sequelize, Doctrine ORM, and others. Every. Single. Time. ORM’s will let you down and keep you from leveraging your database to its fullest potential. Developers like them because you can encapsulate all the logic in the code and treat your database as just a dumb data store. This is a mistake.

Gitlab Docker in Docker with Postgres

Gitlab Docker in Docker with Postgres

I’m embarrassed this took me longer than expected, but here is a .gitlab-ci.yml that will fire up Docker in Docker (so you can build and run containers) and run Postgres to use in your contract tests.

Stupid Postgres Tricks

Stupid Postgres Tricks

I was curious, how many day’s old am I? I suppose I could solve this in many different programming languages, but thought “PG has really good date management features, let me try that”. So here it is.

Delete All Tables in a Postgres database

Delete All Tables in a Postgres database

This doesn’t happen every day, but once in a while you may find yourself needing to remove all the tables/functions/views from a PostgreSQL database. The key is you don’t want to delete the database itself. Maybe you are on a hosted solution where you don’t really have access to drop/restore a database. For example, I’m using Heroku’s Postgres service and dropping the database is not an option.

Database Field Naming Notes

Let’s look at a few ways we can name our database fields. This is mostly subjective, with some personal opinion mixed in for added velocity.

PostgreSQL Performance Notes

Databases are magic from my perspective. They take in queries, find all the information you tasked it to find, and POOF. In the blink of an eye, there it is, all packaged up nice and neat. Or it blows up in your face, but that never happens, right? Let’s take a look at some steps we can take when things are not returned in the blink of and eye. What can we do to improve our database performance.

Postgres Database Design Notes

I love projects where I’m learning something new, don’t you? When I get in a project, I want to be learning new things on a regular basis, otherwise I grow restless. Lately, I’ve been on a pretty big project for a client designing a backend system (GraphQL + Node.js + Postgres). I can’t go into too much detail, but we’ve leveraged Postgres as our main data store and in the process we’ve had to level up on our Postgres skills. This post consists of random notes about PG that I didn’t know a few months ago.

Using JSON functions in PostgreSQL to support GraphQL

Using JSON functions in PostgreSQL to support GraphQL

I love PostgreSQL, always have. I remember, it was easily more than a decade ago, when I first ran into PostgreSQL (PG). It seemed all major open source projects used MySQL. When I learned PG was also open source, plus had more SQL compliant features, I knew it would someday become the de facto open source database. At the time, the client tools, support, and pure speed were not there, but the foundation for a great product existed.