https://github.com/wmfs/pg-delta-file
Outputs change-only-update CSV files (or “delta” files) that contain all the necessary actions required to re-synchronize rows in a cloned table.
https://github.com/wmfs/pg-delta-file
package postgresql tymly
Last synced: 28 days ago
JSON representation
Outputs change-only-update CSV files (or “delta” files) that contain all the necessary actions required to re-synchronize rows in a cloned table.
- Host: GitHub
- URL: https://github.com/wmfs/pg-delta-file
- Owner: wmfs
- License: mit
- Created: 2018-06-11T11:38:27.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T08:18:27.000Z (28 days ago)
- Last Synced: 2025-05-13T08:18:42.953Z (28 days ago)
- Topics: package, postgresql, tymly
- Language: JavaScript
- Homepage:
- Size: 525 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pg-delta-file
[](https://tymly.io/)
[](https://www.npmjs.com/package/@wmfs/pg-delta-file)
[](https://circleci.com/gh/wmfs/pg-delta-file)
[](https://codecov.io/gh/wmfs/pg-delta-file)
[](https://www.codefactor.io/repository/github/wmfs/pg-delta-file)
[](https://dependabot.com/)
[](http://commitizen.github.io/cz-cli/)
[](https://standardjs.com)
[](https://github.com/wmfs/tymly/blob/master/packages/pg-concat/LICENSE)> Outputs change-only-update CSV files (or “delta” files) that contain all the necessary actions required to re-synchronize rows in a cloned table.
## Usage
```
const generateDeltaFile = require('pg-delta-file')const deltaInfo = await generateDeltaFiles(
since: '2017-07-16T20:37:26.847Z',
outputFilepath: '/some/temp/dir/people-delta.csv',
actionAliases: {
insert: 'u',
update: 'u',
delete: 'd'
},
createdColumnName: '_created',
modifiedColumnName: '_modified',
transformFunction: (row, callback) => { ... } // optional data transformation
filterFunction: (row) => { ... } // option filter predicate
dryrun: true // optional flag, set true to return info without generating output file
csvExtracts: {
'[schema.]people': [
'PERSON', // Just output a literal
'$ACTION', // Will output 'u' or 'd'
'$ROW_NUM', // Row counter
'@social_security_id', /// Column data
'@first_name',
'@last_name',
'@age'
'$DATESTAMP',
'$TIMESTAMP',
'$DATETIMESTAMP',
],
'[schema2.]address': [
...
]
}
)/*
{
"totalCount": 5,
"people": {
"totalCount": 5
},
"address": {
"totalCount": 3
"filteredCount": 2
}
}
*/
```## Install
```bash
$ npm install pg-delta-file --save
```## License
[MIT](https://github.com/wmfs/pg-delta-file/blob/master/LICENSE)