https://github.com/wmfs/pg-telepods
https://github.com/wmfs/pg-telepods
package postgresql tymly
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/wmfs/pg-telepods
- Owner: wmfs
- License: mit
- Created: 2018-06-11T13:14:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T08:18:43.000Z (18 days ago)
- Last Synced: 2025-05-13T08:19:48.764Z (18 days ago)
- Topics: package, postgresql, tymly
- Language: JavaScript
- Size: 605 KB
- Stars: 0
- Watchers: 7
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pg-telepods
[](https://tymly.io/)
[](https://www.npmjs.com/package/@wmfs/pg-telepods)
[](https://circleci.com/gh/wmfs/pg-telepods)
[](https://codecov.io/gh/wmfs/pg-telepods)
[](https://www.codefactor.io/repository/github/wmfs/pg-telepods)
[](https://dependabot.com/)
[](http://commitizen.github.io/cz-cli/)
[](https://standardjs.com)
[](https://github.com/wmfs/tymly/blob/master/packages/pg-concat/LICENSE)> Takes the contents of one PostgreSQL table, applies a transformation function to each row and ensures a target table is kept in sync
## Install
```bash
$ npm install pg-telepods --save
``````javascript
const pg = require('pg')
const startTelepods = require('pg-telepods')// Make a new Postgres client
const client = new pg.Client('postgres://postgres:postgres@localhost:5432/my_test_db')
client.connect()// Start the Telepods...
startTelepods(
{
client: client,
outputDir: '/some/temp/dir',
source: {
tableName: 'springfield.people',
hashSumColumnName: 'hash_sum'
},
target: {
tableName: 'government.census',
hashSumColumnName: 'origin_hash_sum'
},
join: {
'social_security_id': 'social_security_id' // key = source table column, value = target table column
},
transformFunction: function (sourceRow, callback) {
callback(null, {
'socialSecurityId': sourceRow.socialSecurityId,
'name': sourceRow.firstName + ' ' + sourceRow.lastName,
'town': 'Springfield'
})
}
},
function (err) {
// All data synchronized from people -> census.
}
)
```Before running these tests, you'll need a test PostgreSQL database available and set a `PG_CONNECTION_STRING` environment variable to point to it, for example:
```PG_CONNECTION_STRING=postgres://postgres:postgres@localhost:5432/my_test_db```
```bash
$ npm test
```## License
[MIT](https://github.com/wmfs/pg-telepods/blob/master/LICENSE)