pg-promise TypeError: Invalid “options” parameter

135
January 20, 2020, at 00:30 AM

I am trying to change my files from using the pg package to the pg-promise package. Everything was working fine with the initial pg solution I was using. However, switching over to pg-promise and using the documentation I am getting strange errors during setup.

The latest error:

throw new TypeError('Invalid "options" parameter: ' + JSON.stringify(options));
^
TypeError: Invalid "options" parameter: "postgres://me:complete@localhost:5432/education_be"

My config file:

require('dotenv').config();
const pgp = require('pg-promise');
// === My initial setup just using 'pg'
// const { Pool } = require('pg');
// const pool = new Pool({
//  name: process.env.name,
//  password: process.env.password,
//  host: process.env.host,
//  database: 'education_be',
//  port: process.env.port
// });
// === My first attempt following the guide would receive errors like:
// === Error: Option "user" is not recognized.
const connection = {
    name: 'me',
    password: 'password',
    host: 'localhost',
    database: 'education_be',
    port: 5432
};
// === attempting (unsuccessfully) to just use the address
const db = pgp('postgres://me:complete@localhost:5432/education_be');
module.exports = db;
Rent Charter Buses Company
READ ALSO
Focusing Input Field after hitting next

Focusing Input Field after hitting next

I have an array of forms, with this form

115
If Conditional Always Runs (Hooks, React State)

If Conditional Always Runs (Hooks, React State)

When a user clicks the thumbs up icon it calls a function that adds +1 to the number of likesIt uses a conditional that checks state to see if it has been pressed, to limit an infinite amount of presses

129
How to copy all the mongoose Documents from one collection to another in same Database

How to copy all the mongoose Documents from one collection to another in same Database

I want to copy all the documents from one collection to another in same DBHow can I do that?

213
Capturing number value from url query in node.js (express) and filtering the collection in mongodb

Capturing number value from url query in node.js (express) and filtering the collection in mongodb

I have an users collection in mongodb, have to find a particular user with mobile number as specified in url query parameter get request

195