question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Would you consider a PR or a different branch to switch over to pg-promise?

It would simplify your code a lot, while also making it more reliable 😉

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
eugene1gcommented, May 6, 2017

As a temporary measure, I managed to use pg-promise by providing a mock for the pg object which just wraps native pg-promise magic -

const _mockQueryFn = (queryString, params, queryCallback) => {
  pgPromiseInstance //<--- your reference to the pg-promise instance for the database
    .query(queryString, params)
    .then(result => queryCallback(null, { rows: result }))
    .catch(error => queryCallback(error));
};
const _mockPgObject = {
  connect: (conString, connectCallback) => {
    connectCallback(null, { query: _mockQueryFn }, () => {});
  }
};


// Now use this mock while configuring `session`
app.use(
    session({
      store: new pgSession({
        pg: _mockPgObject
      }),
      secret: "....",
      resave: false,
      saveUninitialized: false,
      cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 }
    })
  );

ping #41

1reaction
eugene1gcommented, May 19, 2017

@voxpelli I’ll do a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

vitaly-t/pg-promise: PostgreSQL interface for Node.js - GitHub
Extensive support for external SQL files; Support for all promise libraries. At its inception in 2015, this library was only adding promises to...
Read more >
pg-promise API - GitHub Pages
Create your Database object from the connection as pgp(connection, [dc]) : const db = pgp(connection);.
Read more >
Top 5 pg-promise Code Examples - Snyk
To help you get started, we've selected a few pg-promise examples, based on popular ways it is used in public projects. Secure your...
Read more >
pg-promise JavaScript and Node.js code examples - Tabnine
Best JavaScript code snippets using pg-promise(Showing top 15 results out of 315). Tabnine vs. GitHub Copilot. Why developers prefer Tabnine over GitHub ...
Read more >
Intro to PG Promise - YouTube
Intro to PG Promise. 1.4K views 2 years ago. Corey Ladovsky. Corey Ladovsky. 186 subscribers. Subscribe. 22. I like this. I dislike this....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found