1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00
budibase/packages/server/src/integrations/postgres.js

49 lines
800 B
JavaScript
Raw Normal View History

2020-11-27 03:43:56 +13:00
const { Client } = require("pg")
const POSTGRES_OPTIONS = {
host: {
type: "string",
required: true,
default: "localhost",
},
port: {
type: "number",
required: true,
default: 5432,
},
database: {
type: "string",
default: "postgres",
},
username: {
type: "string",
default: "root",
},
password: {
type: "password",
default: "root",
},
}
class PostgresIntegration {
constructor(config) {
this.config = config
this.client = new Client(config)
this.connect()
}
async connect() {
return this.client.connect()
}
async query() {
const response = await this.client.query(this.config.query)
return response.rows
}
}
module.exports = {
schema: POSTGRES_OPTIONS,
integration: PostgresIntegration,
}