Create PostgreSQL database & user

In the preceding guides, we covered the basics of implementing a backend application using Node.js and GraphQL. In addition, we detailed the steps necessary to set up Express.js with TypeScript and GraphQL. Mocking allowed us to get Apollo Server up and running as a GraphQL server before implementing the resolvers that are meant to perform the actual work of retrieving and inserting data.
This guide will cover the basics of using TypeORM to connect to a relational database and retrieve and store data in your application.
Now that our GraphQL-based backend application is complete, we must link it to our data store. We'll use TypeORM to abstract the database operations, making it possible to switch to a different DBMS without modifying the code. We'll also cover database table creation and seeding, as well as integrating TypeORM with Apollo.
First you need to create a user and database in your database. In PostgreSQL, you can use the following commands.
First log in PostgreSQL using the following command:
su - postgres
Next, run:
CREATE USER dbuser WITH PASSWORD '12345689';
Next, give the necessary permissions using the following command:
GRANT ALL PRIVILEGES ON * . * TO dbuser@'localhost';
Next, create the database as follows:
FLUSH PRIVILEGES;
create database communitydb;
So long! We have a user named dbuser who logs in with the password 123456789 and a database called communitydb. In the next part, we'll use these credentials to set up TypeORM.
- Author: Ahmed Bouchefra Follow @ahmedbouchefra
-
Date:
Related posts
Seeding test data in TypeORM Setup TypeORM TypeORM Entity & Column decorators Setup TypeORM Create PostgreSQL database & user Angular 14 Apollo Client Setup Angular 14 Apollo Client Setup Debugging Angular applications Configuring CORS with Express.js Mocking GraphQL with Apollo Server GraphQL APIs with Apollo Server & Apollo Studio [Part 2] GraphQL APIs with Apollo Server & Apollo Studio Watch and compile TypeScript code to JavaScript Setup TypeScript with Node.js & Express.js Setup the server with Node.js/Express.js/Apollo Storing data with PostgreSQL and TypeORM Using GraphQL and Apollo for front- and back-end integration Using NVM on Windows How to Use Node.js to Run JavaScript on Servers Modern full-stack single-page apps' architecture 99+ Web Development Projects Challenges