Created
December 1, 2020 07:53
-
-
Save iworkforthem/199efeb51454c763b307817dea7cc9cf to your computer and use it in GitHub Desktop.
expressjs connect to Materialize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const app = express(); | |
const port = 3000; | |
const { Client } = require("pg"); | |
const client = new Client({ | |
host: "127.0.0.1", | |
port: 6875, | |
database: "materialize", | |
}); | |
client.connect(); | |
client.query("SHOW DATABASES", (err, res) => { | |
if (err) { | |
console.log(err.stack); | |
} else { | |
console.log(res.rows); | |
} | |
}); | |
app.get("/", (req, res) => { | |
res.send("Hello World!"); | |
}); | |
app.listen(port, () => { | |
console.log(`express-materialize app listening at http://localhost:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment