Skip to content
mlaanderson edited this page Dec 11, 2017 · 3 revisions

A Connection provides a single connection to a database source. It provides the ability to interact with a database through a common set of commands.

var connection = new Connection("database-js-postgres://user:password@host/database");
var statement = connection.prepareStatement("SELECT username FROM users WHERE username = ? and password = crypt(?, password)");
statement.query(username, password).then((rows) => {
    if (rows.length == 1) {
        console.log('Logged in as ', username);
    } else {
        console.log('Invalid user');
    }
}).catch((error) => {
    console.log(error);
});
Clone this wiki locally