feat(postgresql): add auth and primitive actions
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import knex, { Knex } from 'knex'
|
||||
|
||||
|
||||
const setConfig = async ($: IGlobalVariable) : Promise<Knex<any, unknown[]>> => {
|
||||
const pgClient = knex({
|
||||
client: 'pg',
|
||||
version: $.auth.data.version as string,
|
||||
connection: {
|
||||
host : $.auth.data.host as string,
|
||||
port : $.auth.data.port as number,
|
||||
user : $.auth.data.user as string,
|
||||
password : $.auth.data.password as string,
|
||||
database : $.auth.data.database as string
|
||||
}
|
||||
})
|
||||
|
||||
return pgClient;
|
||||
|
||||
};
|
||||
|
||||
export default setConfig;
|
@@ -0,0 +1,17 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
import { Knex } from 'knex'
|
||||
import logger from '../../../helpers/logger';
|
||||
|
||||
const setParams = async ($: IGlobalVariable, client: Knex<any, unknown[]>) : Promise<Knex.Raw<any>> => {
|
||||
|
||||
const params : any = $.step.parameters.params
|
||||
let paramsObj : IJSONObject = {}
|
||||
params.forEach( (ele: any) => { paramsObj[ele.configParam] = ele.value } )
|
||||
|
||||
for (const key in paramsObj) {
|
||||
const res = await client.raw(`SET ${key} = '${paramsObj[key]}'`);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default setParams;
|
Reference in New Issue
Block a user