mirror of https://github.com/Budibase/budibase.git
nocodelowcodelow-codedockerdocker-composeinternal-projectinternal-toolinternal-toolslow-code-developmentlow-code-development-platformopensourceselfhostedweb-devweb-developmentweb-development-toolswebdevwebdevelopmentworkflow-automationautomationdeveloper-tools
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.4 KiB
83 lines
1.4 KiB
const { Client } = require("pg")
|
|
|
|
const SCHEMA = {
|
|
docs: "https://node-postgres.com",
|
|
datasource: {
|
|
host: {
|
|
type: "string",
|
|
default: "localhost",
|
|
required: true,
|
|
},
|
|
port: {
|
|
type: "number",
|
|
required: true,
|
|
default: 5432,
|
|
},
|
|
database: {
|
|
type: "string",
|
|
default: "postgres",
|
|
required: true,
|
|
},
|
|
user: {
|
|
type: "string",
|
|
default: "root",
|
|
required: true,
|
|
},
|
|
password: {
|
|
type: "password",
|
|
default: "root",
|
|
required: true,
|
|
},
|
|
},
|
|
query: {
|
|
create: {
|
|
type: "sql",
|
|
},
|
|
read: {
|
|
type: "sql",
|
|
},
|
|
update: {
|
|
type: "sql",
|
|
},
|
|
delete: {
|
|
type: "sql",
|
|
},
|
|
},
|
|
}
|
|
|
|
class PostgresIntegration {
|
|
constructor(config) {
|
|
this.config = config
|
|
this.client = new Client(config)
|
|
this.connect()
|
|
}
|
|
|
|
async connect() {
|
|
return this.client.connect()
|
|
}
|
|
|
|
async create({ sql }) {
|
|
const response = await this.client.query(sql)
|
|
return response.rows
|
|
}
|
|
|
|
async read({ sql }) {
|
|
const response = await this.client.query(sql)
|
|
return response.rows
|
|
}
|
|
|
|
async update({ sql }) {
|
|
const response = await this.client.query(sql)
|
|
return response.rows
|
|
}
|
|
|
|
async delete({ sql }) {
|
|
const response = await this.client.query(sql)
|
|
return response.rows
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
schema: SCHEMA,
|
|
integration: PostgresIntegration,
|
|
}
|
|
|