Serious problem with PG.js

110 views
Skip to first unread message

Julien

unread,
Apr 25, 2014, 9:58:01 PM4/25/14
to tot...@googlegroups.com
HI Peter,

I have a serious problem with Postgres: See this error.

// override the framework prototype
framework.database = function(dbName, callback) {
    return new pg.connect('postgres://user:1234@host:5432/' + dbName, callback);
};

self.database('table123', function(err, client, done) {

};

TypeError: Cannot call method 'getOrCreate' of undefined TypeError: Cannot call method 'getOrCreate' of undefined at new PG.connect (/d/node_modules/pg.js/lib/index.js:36:25) at EventEmitter.framework.database (eval at <anonymous> (/d/node_modules/total.js/index.js:1:18228), <anonymous>:5:12) at Object.Controller.database (/d/node_modules/total.js/index.js:5:4795) at Object.view_homepage (/d/controllers/mapping.js:11:10)





Thank you for your help

Peter Širka

unread,
Apr 26, 2014, 1:44:46 AM4/26/14
to tot...@googlegroups.com
Hi Julien,
this is a problem of Postgre module. I'd like to help you but I can't :-/


clement...@gmail.com

unread,
Jun 19, 2014, 12:39:12 PM6/19/14
to tot...@googlegroups.com
Hi,

I am encountering the same problem. Were you able to solve the issue?

Thanks

Peter Širka

unread,
Jun 19, 2014, 12:44:34 PM6/19/14
to tot...@googlegroups.com, clement...@gmail.com
Hi Clement,
this is problem of module PG. Try to create an example without total.js and use PG module.
Give me a feedback whether it works.

Thanks.

clement...@gmail.com

unread,
Jun 20, 2014, 4:22:18 AM6/20/14
to tot...@googlegroups.com, clement...@gmail.com
Hi,

I tried this, which works. I still haven't figured out why the first doesn't work though, I'll keep you posted if I find something.

Clément

var pg = require('pg');
var conString = "postgres://xxxx:xxx@localhost:5432/dbxxx";

var client = new pg.Client(conString);
client.connect();


//queries are queued and executed one after another once the connection becomes available
var x = 1000;

while(x>0)
{
client.query("INSERT INTO users(first_name, last_name) values($1, $2)", ['first_' + x, 'last_' + x]);
x = x - 1;
}

var query = client.query("SELECT * FROM users");
//fired after last row is emitted

query.on('row', function(row) {
console.log(row);
});

query.on('end', function() {
client.end();
});

Peter Širka

unread,
Jun 20, 2014, 4:44:03 AM6/20/14
to tot...@googlegroups.com, clement...@gmail.com
Thanks.
Reply all
Reply to author
Forward
0 new messages