Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wmfs/pg-telepods
https://github.com/wmfs/pg-telepods
package postgresql tymly
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/wmfs/pg-telepods
- Owner: wmfs
- License: mit
- Created: 2018-06-11T13:14:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-04T10:10:35.000Z (3 months ago)
- Last Synced: 2024-11-04T11:45:22.965Z (3 months ago)
- Topics: package, postgresql, tymly
- Language: JavaScript
- Size: 551 KB
- Stars: 0
- Watchers: 8
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pg-telepods
[![Tymly Package](https://img.shields.io/badge/tymly-package-blue.svg)](https://tymly.io/)
[![npm (scoped)](https://img.shields.io/npm/v/@wmfs/pg-telepods.svg)](https://www.npmjs.com/package/@wmfs/pg-telepods)
[![CircleCI](https://circleci.com/gh/wmfs/pg-telepods.svg?style=svg)](https://circleci.com/gh/wmfs/pg-telepods)
[![codecov](https://codecov.io/gh/wmfs/pg-telepods/branch/master/graph/badge.svg)](https://codecov.io/gh/wmfs/pg-telepods)
[![CodeFactor](https://www.codefactor.io/repository/github/wmfs/pg-telepods/badge)](https://www.codefactor.io/repository/github/wmfs/pg-telepods)
[![Dependabot badge](https://img.shields.io/badge/Dependabot-active-brightgreen.svg)](https://dependabot.com/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](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)