![]() ![]() So, it seems like the DB connection is not working, thus the PostgreSQL server connection parameters are wrong. TypeError: Cannot read properties of undefined (reading 'query')Īt /Users/user/code/src/routes/:9:31Īt Layer.handle (/Users/user/code/node_modules/express/lib/router/layer.js:95:5)Īt next (/Users/user/code/node_modules/express/lib/router/route.js:144:13)Īt Route.dispatch (/Users/user/code/node_modules/express/lib/router/route.js:114:3)Īt /Users/user/code/node_modules/express/lib/router/index.js:284:15Īt Function.process_params (/Users/user/code/node_modules/express/lib/router/index.js:346:12)Īt next (/Users/user/code/node_modules/express/lib/router/index.js:280:10)Īt Function.handle (/Users/user/code/node_modules/express/lib/router/index.js:175:3)Īt router (/Users/user/code/node_modules/express/lib/router/index.js:47:12) This is the error I got on the terminal: /Users/user/code/src/routes/:9Ĭonst result = await pool.query('SELECT NOW()') Like this: docker run -d -name some-postgres -e POSTGRESPASSWORDmysecretpassword -e POSTGRESUSERsimha -e POSTGRESDBbtgapp postgres:11-alpine. In the routes folder, I have the file to list endpoints. Add to that, that the database and user that you want created on startup - can be handled in the environment variables alone for the official postgres image. ![]() This is my index.js file: const express = require('express') Ĭonst taskRoutes = require('./routes/tasks.routes') I'm working on a basic JS application using the PERN stack. You can see from the image the PostgreSQL server connection parameters. Without further ado let’s run PostgreSQL database in a Docker container In order to follow next steps you need to have installed Docker on your PC. Then, changes were reflected on where pgAdmin was running. I accessed the PostgreSQL server on the terminal and created tasksdb database and task table, following the code below: docker exec -it my-own-postgres psql -U postgres I found the PostgreSQL server host executing docker inspect my-own-postgres, which retrieves 172.17.0.2 for IPAddress. I've entered pgAdmin through and added PostgreSQL server which is in the host 172.17.0.2 and on port 5432. I'm running PostgreSQL & PgAdmin using docker, following this tutorial. To set up Datalore, unpack the downloaded archive and open docker-compose.yaml from the archivefolder/docker-compose folder in any text editor. Install Datalore Download an archive with the configuration files. I have a question regarding using the pg library to connect nodeJS with the Postgres database. You need to have the database running before you create the users. Basic Datalore installation Follow the instruction to install Datalore using the selected method. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |