{"id":1917,"date":"2024-03-18T06:15:43","date_gmt":"2024-03-18T06:15:43","guid":{"rendered":"https:\/\/www.aviator.co\/blog\/?p=1917"},"modified":"2025-09-25T12:02:27","modified_gmt":"2025-09-25T12:02:27","slug":"use-postgres-js-to-create-powerful-database-applications","status":"publish","type":"post","link":"https:\/\/www.aviator.co\/blog\/use-postgres-js-to-create-powerful-database-applications\/","title":{"rendered":"Using Postgres.js to Create Powerful Database Applications"},"content":{"rendered":"\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<figure class=\"wp-block-image\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"574\" src=\"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js-1024x574.png\" alt=\"postgres-js\" class=\"wp-image-1921\" srcset=\"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js-1024x574.png 1024w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js-300x168.png 300w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js-768x430.png 768w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js.png 1456w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n\n<p><a href=\"https:\/\/github.com\/porsager\/postgres\">Postgres.js<\/a> is a lean and powerful JavaScript library for interfacing with PostgreSQL databases. It allows you to perform common database operations, such as creating, reading, updating, and deleting (CRUD) records, all with the simplicity and flexibility of JavaScript.<\/p>\n\n\n\n<p>In this article, you&#8217;ll learn how to use Postgres.js to quickly build a scalable application using a PostgreSQL database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Does Postgres.js Work<\/h2>\n\n\n\n<p>Beyond having the use and flexibility of JavaScript, Postgres.js also provides the following benefits:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Increases efficiency:<\/strong> Postgres.js is designed to be lean and fast, which means it has a small footprint and executes queries quickly.&nbsp;<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/github.com\/porsager\/postgres#error-handling\" target=\"_blank\" rel=\"noopener\" title=\"\">Streamlines error handling<\/a>:<\/strong> Postgres.js provides detailed error objects that make it easier to understand what went wrong when a query fails.&nbsp;<\/li>\n\n\n\n<li><strong>Reduces code complexity<\/strong>: With Postgres.js, you can write SQL queries directly in your JavaScript code without requiring string concatenation or manual escaping.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>Whether you&#8217;re building a small personal project or a large-scale enterprise application, Postgres.js has the features and capabilities to meet your needs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Postgres.js Use Cases<\/h3>\n\n\n\n<p>Postgres.js can be used in a variety of real-world scenarios, including the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Querying data:<\/strong> Imagine you&#8217;re building a blog platform. You have a PostgreSQL database that stores all your blog posts. With Postgres.js, you can easily retrieve all the blog posts on your website like this:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>const posts = await sql`SELECT * FROM posts`;<\/code><\/pre>\n\n\n\n<p>This line of code fetches all the records from the <code>posts<\/code> table in your database, which can then be sent to the frontend for display.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Inserting\/updating\/deleting records:<\/strong> If you&#8217;re working on a task management application, users can use Postgres.js to easily create, update, or delete tasks. For example, to update a task, you might do something like this:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>await sql`UPDATE tasks SET title='Buy Groceries' WHERE id = ${taskId}`;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Creating\/altering database objects:<\/strong> If you&#8217;re setting up a new e-commerce platform, you need to create tables for products, customers, and orders as part of the setup. With Postgres.js, you can execute the following SQL command, which creates a new <code>products<\/code> table with <code>id<\/code>, <code>name<\/code>, and <code>price<\/code> columns:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>await sql`\n&nbsp;&nbsp;CREATE TABLE products (\n&nbsp;&nbsp;&nbsp;&nbsp;id SERIAL PRIMARY KEY,\n&nbsp;&nbsp;&nbsp;&nbsp;name TEXT NOT NULL,\n&nbsp;&nbsp;&nbsp;&nbsp;price NUMERIC NOT NULL\n&nbsp;&nbsp;)\n`;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Started with Postgres.js<\/h2>\n\n\n\n<p>Now that you know a little bit more about Postgres.js, it&#8217;s time to begin experimenting with it on your own! In this article, you&#8217;ll be building a simple to-do manager.<\/p>\n\n\n\n<p>Before you begin, you need the following prerequisites:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/nodejs.org\/en\/download\">Node.js<\/a> (version 20.10.0 or greater)<\/li>\n\n\n\n<li>An IDE for working with JavaScript-based applications<\/li>\n\n\n\n<li>Chrome browser (Version 119 or greater) to view\/interact with the frontend app<\/li>\n\n\n\n<li><a href=\"https:\/\/git-scm.com\/downloads\" target=\"_blank\" rel=\"noopener\" title=\"\">Git client<\/a> to clone and work with the <a href=\"https:\/\/github.com\/rajkumarvenkatasamy\/database-applications-using-postgres-js.git\" target=\"_blank\" rel=\"noopener\" title=\"\">GitHub repository<\/a> for this tutorial.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Clone the Project<\/h3>\n\n\n\n<p>The first thing you need to do is clone the prebuilt project folders from this <a href=\"https:\/\/github.com\/rajkumarvenkatasamy\/database-applications-using-postgres-js.git\" target=\"_blank\" rel=\"noopener\" title=\"\">GitHub repository<\/a> with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/rajkumarvenkatasamy\/database-applications-using-postgres-js.git<\/code><\/pre>\n\n\n\n<p>This repository consists of two folders: one for the frontend application and another for the backend application.<\/p>\n\n\n\n<p>The frontend is a barebones application based on <a href=\"https:\/\/vuejs.org\/\">Vue technology<\/a> with a simple user interface for a to-do manager. The repository&#8217;s backend source code contains comments indicating where the integration to the database needs to happen.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set Up the Frontend App<\/h3>\n\n\n\n<p>Once you&#8217;ve cloned the project, switch to the frontend directory, <code>todo-manager-frontend<\/code>, and execute the following command, which installs the dependencies specified in the <code>package.json<\/code> file:<br>npm install<\/p>\n\n\n\n<p>The frontend application allows you to list, create, update, and delete to-do items. However, currently, these operations are not functional because the database integration is not yet implemented. That&#8217;s what you&#8217;ll do next.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Set Up a Local Postgres Instance<\/h3>\n\n\n\n<p>Before you can start working with Postgres.js, you need a PostgreSQL database. You can set up a local Postgres instance by following <a href=\"https:\/\/www.postgresql.org\/download\/\" title=\"\">these instructions<\/a>. The installation steps and startup instructions vary based on the operating system and its distribution flavor, so always refer to the latest official documentation link for up-to-date information.<\/p>\n\n\n\n<p>You can also install Postgres via Docker if you have <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Docker installed<\/a> on your machine.<\/p>\n\n\n\n<p>Once the database is installed and is up and running, open a terminal and execute the following command to connect the <code>psql<\/code> prompt. By default, Postgres comes with the user, <code>postgres<\/code> that you&#8217;ll use here:<br>psql -u postgres<\/p>\n\n\n\n<p>Set the password for this user using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER postgres WITH PASSWORD 'P@ssw0rd';<\/code><\/pre>\n\n\n\n<p>Then, execute the following to create your app&#8217;s <code>todo<\/code> database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>create database todo;<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong> If you&#8217;re using Docker, you have to connect to the running Postgres container terminal before you execute these commands. To do so, open a terminal and execute the following command, which connects the Postgres container in an interactive mode:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it postgres-db-1 bash<\/code><\/pre>\n\n\n\n<p><code>postgres-db-1<\/code> is the running container name in this command snippet.<\/p>\n\n\n\n<p>Once you&#8217;re connected to the running container&#8217;s terminal session, execute the previously shared commands to connect the <code>psql<\/code> prompt with the <code>postgres<\/code> user and create the database for this tutorial.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prepare the Backend Application<\/h3>\n\n\n\n<p>Now that you have a running Postgres database, it&#8217;s time to prepare the backend application and get it ready to interact with the Postgres database using Postgres.js.<\/p>\n\n\n\n<p>Switch to the backend directory, <code>todo-manager-backend<\/code>, and execute the following command to install the dependencies, including the Postgres.js library:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install<\/code><\/pre>\n\n\n\n<p>You should see an output that looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>added 65 packages, and audited 66 packages in 2s<\/code><\/pre>\n\n\n\n<p>12 packages are looking for funding<\/p>\n\n\n\n<p>&nbsp;&nbsp;run <code>npm fund<\/code> for details<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>found 0 vulnerabilities<\/code><\/pre>\n\n\n\n<p>Alternatively, you can also install the Postgres.js library using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install postgres<\/code><\/pre>\n\n\n\n<p>Set up the database connection details so that the Postgres.js library can establish connectivity and know which database it needs to connect to. This will be done in a <code>database.js<\/code> file.<\/p>\n\n\n\n<p>Once the dependencies are installed, open the backend project directory in your favorite IDE and edit the <code>app.js<\/code> file. This is the main entry point of the backend application, which is set to listen to incoming requests on port 3000:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.listen(3000, () =&gt; {\n  console.log('Server running on http:\/\/localhost:3000');\n});<\/code><\/pre>\n\n\n\n<p>Now you&#8217;ll create a table named <code>todos<\/code> to store the to dos. Paste the following comments in the <code>app.js<\/code> file:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Define a function to create the todos table if it doesn't exist\nasync function createTable() {\n&nbsp;&nbsp;&nbsp;&nbsp;await sql`\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CREATE TABLE IF NOT EXISTS todos (\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id SERIAL PRIMARY KEY,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title TEXT NOT NULL\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)\n&nbsp;&nbsp;&nbsp;&nbsp;`;\n&nbsp;&nbsp;}\n\n&nbsp;&nbsp;\/\/ Call the function at the start of your application\n&nbsp;&nbsp;createTable().catch(console.error);<\/code><\/pre>\n\n\n\n<p>Next, edit the <code>database.js<\/code> file to include the following to connect your app to the <code>todo<\/code> database using <code>psql<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ const sql = postgres('postgres:\/\/username:password@localhost\/database');<\/code><\/pre>\n\n\n\n<p>Here, the variable <code>sql<\/code> has the connection property set to interact with the Postgres database. Uncomment the previous statement and edit it with your own Postgres details like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const sql = postgres('postgres:\/\/postgres:P@ssw0rd@localhost:5434\/todo');<\/code><\/pre>\n\n\n\n<p>The Postgres.js library supports numerous configuration options to interact with the Postgres database. To explore other options, refer to <a href=\"https:\/\/github.com\/porsager\/postgres?tab=readme-ov-file#all-postgres-options\">the library&#8217;s official documentation<\/a>.<\/p>\n\n\n\n<p>Now that you have your connection identifier set to interact with your Postgres database and a table to store the to dos, it&#8217;s time to define the <a href=\"https:\/\/www.techtarget.com\/searchapparchitecture\/definition\/API-endpoint\" target=\"_blank\" rel=\"noopener\" title=\"\">API endpoints<\/a> to help you complete various actions related to to-do tasks retrieval, creation, update, and deletion. Paste the following code snippet at the end of the <code>app.js<\/code> file:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Get all to-dos\napp.get(\"\/todos\", async (req, res) =&gt; {\n&nbsp;&nbsp;const todos = await sql`SELECT * FROM todos`;\n&nbsp;&nbsp;res.json(todos);\n});\n\n\/\/ Get a to-do task based on id\napp.get(\"\/todos\/:id\", async (req, res) =&gt; {\n&nbsp;&nbsp;const { id } = req.params;\n&nbsp;&nbsp;const todos = await sql`SELECT * FROM todos where id = ${id}`;\n&nbsp;&nbsp;res.json(todos);\n});\n\n\/\/ Create a new to-do\napp.post(\"\/todos\", async (req, res) =&gt; {\n&nbsp;&nbsp;const { title } = req.body;\n&nbsp;&nbsp;const todo =\n&nbsp;&nbsp;&nbsp;&nbsp;await sql`INSERT INTO todos (title) VALUES (${title}) RETURNING *`;\n&nbsp;&nbsp;res.status(201).json(todo);\n});\n\n\/\/ Update a to-do\napp.put(\"\/todos\/:id\", async (req, res) =&gt; {\n&nbsp;&nbsp;const { id } = req.params;\n&nbsp;&nbsp;const { title } = req.body;\n&nbsp;&nbsp;const todo =\n&nbsp;&nbsp;&nbsp;&nbsp;await sql`UPDATE todos SET title = ${title} WHERE id = ${id} RETURNING *`;\n&nbsp;&nbsp;res.json(todo);\n});\n\n\/\/ Delete a to-do\napp.delete(\"\/todos\/:id\", async (req, res) =&gt; {\n&nbsp;&nbsp;const { id } = req.params;\n&nbsp;&nbsp;await sql`DELETE FROM todos WHERE id = ${id}`;\n&nbsp;&nbsp;res.status(204).end();\n});<\/code><\/pre>\n\n\n\n<p>For these endpoints, you use <code>await sql<\/code> statements, which are part of the <a href=\"https:\/\/github.com\/porsager\/postgres?tab=readme-ov-file#table-of-contents\">Postgres.js library syntax<\/a> and interact with the Postgres database table.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run the Backend Application<\/h3>\n\n\n\n<p>Now, it&#8217;s time to execute the app and use a simple GET endpoint to retrieve the tasks (which currently don&#8217;t exist).<\/p>\n\n\n\n<p>Open a new command terminal, switch to the backend directory, and execute the following command:<br>node app.js<\/p>\n\n\n\n<p>Your output should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Server running on http:\/\/localhost:3000<\/code><\/pre>\n\n\n\n<p>Next, open a Chrome browser and paste the following URL: <code>http:\/\/localhost:3000\/todos<\/code>. You should see an output that looks like this with an empty list structure (<em>ie<\/em> empty square brackets):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/l6RWGUp.png\" alt=\"GET to-dos empty list structure\"\/><\/figure>\n\n\n\n<p>Now that the backend app is working, it&#8217;s time to move back to the frontend app to test the whole workflow.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run the Frontend Application<\/h3>\n\n\n\n<p>The cloned repository already contains the frontend code you need to work with the API endpoints of your backend application. That means you can just run the frontend application and test your to-do workflow.<\/p>\n\n\n\n<p>Open a new command terminal, switch to the frontend app directory, and execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run serve<\/code><\/pre>\n\n\n\n<p>You should see an output similar to the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DONE&nbsp; Compiled successfully in 68ms\nApp running at:\n&nbsp;&nbsp;- Local: &nbsp; http:\/\/localhost:8080\/\n&nbsp;&nbsp;- Network: &#91;http:\/\/192.168.29.207:8080\/](http:\/\/192.168.29.207:8080\/)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12:19:59 PM<\/code><\/pre>\n\n\n\n<p>Next, open a Chrome browser and paste the following URL:<code> http:\/\/localhost:8080\/<\/code>. You should see an output that looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"773\" height=\"392\" src=\"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/6yDuuGT-Imgur.png\" alt=\"\" class=\"wp-image-1920\" srcset=\"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/6yDuuGT-Imgur.png 773w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/6yDuuGT-Imgur-300x152.png 300w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/6yDuuGT-Imgur-768x389.png 768w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><\/figure>\n\n\n\n<p>If you click on the link <strong>Create a new todo<\/strong>, you&#8217;ll see a screen where you can create a new to-do item:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/8LRf063.png\" alt=\"Create a to-do item\"\/><\/figure>\n\n\n\n<p>Create a new to-do item that says &#8220;Buy Groceries&#8221; and click <strong>Create<\/strong>. Once you&#8217;ve created the to-do item, you&#8217;ll be taken back to the home page, where the recently created to-do list will be shown along with the <strong>Update<\/strong> and <strong>Delete<\/strong> options:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/IqsUKJa.png\" alt=\"Home page with to dos\"\/><\/figure>\n\n\n\n<p>Feel free to explore the update and delete options on your own using the frontend app.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Transactions Support by Postgres.js<\/h3>\n\n\n\n<p>The Postgres.js library also supports a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Database_transaction\">transactions feature<\/a> out of the box.<\/p>\n\n\n\n<p>For this application, you can replace any of the DML statements (<em>ie<\/em> insert\/update\/delete) with a transactions-based syntactic approach and still achieve the same result in the app.<\/p>\n\n\n\n<p>To give you a glimpse of transactions-oriented syntax usage, replace the entire <code>app.post<\/code> code block that handles the creation of a new to-do item in the <code>app.js<\/code> file with the following code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create a new to-do\napp.post(\"\/todos\", async (req, res) =&gt; {\n&nbsp;&nbsp;const { title } = req.body;\n&nbsp;&nbsp;const &#91;todo] = await sql.begin(async (sql) =&gt; {\n&nbsp;&nbsp;&nbsp;&nbsp;const &#91;todo] = await sql`\n&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO todos (title) VALUES (${title}) RETURNING *\n&nbsp;&nbsp;&nbsp;&nbsp;`;\n&nbsp;&nbsp;&nbsp;&nbsp;return &#91;todo];\n&nbsp;&nbsp;});\n&nbsp;&nbsp;res.status(201).json(todo);\n});<\/code><\/pre>\n\n\n\n<p>Save the <code>app.js<\/code> file and restart the backend and frontend app again. You should see a similar result to what you received previously.<\/p>\n\n\n\n<p>For more details on using the transactions features of the Postgres.js library, refer to <a href=\"https:\/\/github.com\/porsager\/postgres?tab=readme-ov-file#transactions\">this official documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Postgres.js is a powerful library to connect with PostgreSQL in a JavaScript application. Its lean and efficient design allows for the fast execution of queries. Additionally, its simple syntax makes it easy to create, read, update, and delete records, as well as perform more complex transactions and queries.<\/p>\n\n\n\n<p>In this article, you learned how to utilize the Postgres.js library to create a powerful database application. With this knowledge, you&#8217;re now equipped to use Postgres.js to create powerful, efficient, and scalable database applications. Happy coding!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/www.aviator.co\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Aviator<\/a>: Automate your cumbersome merge processes<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.aviator.co\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"727\" src=\"https:\/\/blog.aviator.co\/wp-content\/uploads\/2022\/08\/blog-cta-1024x727.png\" alt=\"\" class=\"wp-image-57\" srcset=\"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2022\/08\/blog-cta-1024x727.png 1024w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2022\/08\/blog-cta-300x213.png 300w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2022\/08\/blog-cta-768x545.png 768w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2022\/08\/blog-cta-1536x1090.png 1536w, https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2022\/08\/blog-cta-2048x1454.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Aviator automates tedious developer workflows by managing git Pull Requests (PRs) and continuous integration test (CI) runs to help your team avoid broken builds, streamline cumbersome merge processes, manage cross-PR dependencies, and handle flaky tests while maintaining their security compliance.<\/p>\n\n\n\n<p>There are 4 key components to Aviator:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>MergeQueue<\/strong>&nbsp;\u2013 an automated queue that manages the merging workflow for your GitHub repository to help protect important branches from broken builds. The Aviator bot uses GitHub Labels to identify Pull Requests (PRs) that are ready to be merged, validates CI checks, processes semantic conflicts, and merges the PRs automatically.<\/li>\n\n\n\n<li><strong>ChangeSets<\/strong>&nbsp;\u2013 workflows to synchronize validating and merging multiple PRs within the same repository or multiple repositories. Useful when your team often sees groups of related PRs that need to be merged together, or otherwise treated as a single broader unit of change.<\/li>\n\n\n\n<li><strong>TestDeck<\/strong>&nbsp;\u2013 a tool to automatically detect, take action on, and process results from flaky tests in your CI infrastructure.<\/li>\n\n\n\n<li><strong>Stacked PRs CLI<\/strong>&nbsp;\u2013 a command line tool that helps developers manage cross-PR dependencies. This tool also automates syncing and merging of stacked PRs. Useful when your team wants to promote a culture of smaller, incremental PRs instead of large changes, or when your workflows involve keeping multiple, dependent PRs in sync.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Postgres.js is powerful JavaScript library for interfacing with PostgreSQL databases. Learn how to use this library to quickly build a scalable application.<\/p>\n","protected":false},"author":27,"featured_media":1921,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[301],"tags":[29,90,47],"class_list":["post-1917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials-guides"],"blocksy_meta":[],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.aviator.co\/blog\/wp-content\/uploads\/2024\/03\/postgres.js.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/posts\/1917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/comments?post=1917"}],"version-history":[{"count":13,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/posts\/1917\/revisions"}],"predecessor-version":[{"id":4917,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/posts\/1917\/revisions\/4917"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/media\/1921"}],"wp:attachment":[{"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/media?parent=1917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/categories?post=1917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aviator.co\/blog\/wp-json\/wp\/v2\/tags?post=1917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}