I want to use PostgreSQL in the client side. is that possible? can i have this code?
in my server.js
var pg = require('pg');
in my client side
var conString = "postgres://postgres:pass@localhost/mydb";
var client = new pg.Client(conString);
client.connect();
var query = client.query("SELECT * FROM users ");
query.on('row', function(row) {
alert(row.name);
});
i tried this code but nothing happened. though can i have a code similar to this, where i connect PostgreSQL and use queries on the client scripts.
No, that's (obviously) not possible. You wouldn't want to let a client access your database directly anyway. Besides that, even though you use JS on both the client and server side it's not different from what happens if you use e.g. PHP or Python on the server - the only communication between it is possible via AJAX and regular http requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With