Commit 65c585d0 authored by Panagiotis Skarvelis's avatar Panagiotis Skarvelis
Browse files

instructions for postgresql

parent 44c1994d
......@@ -35,8 +35,16 @@ console.log(auditRecordDB({},new FileEngine('/tmp/auditRecords')))
}
```
### Prostgresql
To work with Postgresql you need to use `PostgresqlEngine` instead of `FileEngine`
And you need to install native `libpg` library for Postgresql
On macOS: brew install libpq
On Ubuntu/Debian: apt-get install libpq-dev g++ make
On RHEL/CentOS: yum install postgresql-devel
```
//you can also use PostgresSqlEngine via enviroment variables
//you can use the PostgresSqlEngine via enviroment variables
import auditRecordDB,{PostgresSqlEngine} from 'AuditRecordDB';
const main = () =>{
process.env.PGHOST='localhost'
......@@ -53,24 +61,24 @@ console.log(auditRecordDB({},new PostgresSqlEngine()))
```
//or via connection string
import auditRecordDB,{PostgresSqlEngine} from 'AuditRecordDB';
const connectionString = 'postgresql://dbuser:secretpassword@localhost:3211/audit'
const connectionString = 'postgresql://dbuser:secretpassword@localhost:5432/audit'
const main = () =>{
console.log(auditRecordDB({},new PostgresSqlEngine()))
}
```
```
//The postgresql engine asumes that you have already create the table `auditRecords` in the database, and that the table has the following columns:
//The postgresql engine asumes that you have already create the table `audit_records` in the database, and that the table has the following columns:
//auditUnit: text
//auditTransactionId: text
//auditProtocol: text
//auditTransactionDate: timestamp
//auditTransactionDate: text
//auditUserIp: text
//auditUserId: text
//
//if you have already a table on Postgresql you can use it by mapping the columns to the AuditRecord
import auditRecordDB,{PostgresSqlEngine} from 'AuditRecordDB';
const connectionString = 'postgresql://dbuser:secretpassword@localhost:3211/audit'
const connectionString = 'postgresql://dbuser:secretpassword@localhost:5432/audit'
const main = () =>{
console.log(auditRecordDB({},new PostgresSqlEngine({
tableName:'audit_records',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment