Thursday, 11 May 2017

pg-promise set schema NodeJs

I am using pg-promise to work with nodeJS and postgress, but when i try to querie my User table it retrives me the superUser, i think it is related to the fact that i haven«t a schema set yet so he search on the default 1, how can i set the schema on the code?

i tried this:

var express = require('express');
var app = express();
const PORT = 8080;

var pgp = require('pg-promise')(/*options*/)
var db = pgp('postgres://postgres:randompassword@localhost:5432/appname')


app.listen(PORT,function(){
    console.log("listening to port: " + PORT);
})

db.any('SELECT * FROM User', [true])
    .then(function(data) {
        console.log(data);
    })
    .catch(function(error) {
        console.log(error);
    });



via Antonio Costa

No comments:

Post a Comment