Commit 44c1994d authored by Panagiotis Skarvelis's avatar Panagiotis Skarvelis
Browse files

update future readme

parent 627e4bdd
......@@ -35,7 +35,64 @@ console.log(auditRecordDB({},new FileEngine('/tmp/auditRecords')))
}
```
```
//you can also use PostgresSqlEngine via enviroment variables
import auditRecordDB,{PostgresSqlEngine} from 'AuditRecordDB';
const main = () =>{
process.env.PGHOST='localhost'
process.env.PGUSER='dbuser'
process.env.PGPASSWORD='secretpassword'
process.env.PGDATABASE='audit'
process.env.PGPORT='5432'
console.log(auditRecordDB({},new PostgresSqlEngine()))
}
```
```
//or via connection string
import auditRecordDB,{PostgresSqlEngine} from 'AuditRecordDB';
const connectionString = 'postgresql://dbuser:secretpassword@localhost:3211/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:
//auditUnit: text
//auditTransactionId: text
//auditProtocol: text
//auditTransactionDate: timestamp
//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 main = () =>{
console.log(auditRecordDB({},new PostgresSqlEngine({
tableName:'audit_records',
columns:{
auditUnit:'audit_unit',
auditTransactionId:'audit_transaction_id',
auditProtocol:'audit_protocol',
auditTransactionDate:'audit_transaction_date',
auditUserIp:'audit_user_ip',
auditUserId:'audit_user_id'
}
})))
}
```
# AuditEngine
For now only file system storage engine is implement, but you can extend to store to 'real' database, look at `FileEngine.ts` for example.
As default a file storage engine `FileEngine` is implement, please mind to change the storage path to your needs.
You can also use PostgreSql Engine.
To make it work have to pass enviroment variables according to the documentation of the LIBPGSQL library. https://www.postgresql.org/docs/9.1/libpq-envars.html
Also you can extend the store to another 'real' database, look at `FileEngine.ts` and `PostgreSqlEngine.ts` for examples.
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