# pg-telepods

> Takes the contents of one PostgreSQL table, applies a transformation function to each row and ensures a target table is kept in sync

Latest version **0.0.4** (published 2017-09-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install pg-telepods
pnpm add pg-telepods
yarn add pg-telepods
bun add pg-telepods
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2017-09-10 |
| First published | 2017-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 121 |
| Author | Jasvinder Bahra |
| Maintainers | timneedham |
| Keywords | etl, pg, postgresql |

## Links

- npm: https://www.npmjs.com/package/pg-telepods
- Repository: https://github.com/wmfs/tymly
- Homepage: https://github.com/wmfs/tymly#readme
- Issues: https://github.com/wmfs/tymly/issues
- npm.io page: https://npm.io/package/pg-telepods

## Dependencies (9)

- [boom](https://npm.io/package/boom.md) ^5.2.0
- [async](https://npm.io/package/async.md) ^2.5.0
- [debug](https://npm.io/package/debug.md) ^2.6.8
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [make-dir](https://npm.io/package/make-dir.md) ^1.0.0
- [supercopy](https://npm.io/package/supercopy.md) ^0.0.4
- [csv-string](https://npm.io/package/csv-string.md) ^2.3.2
- [camelcase-keys](https://npm.io/package/camelcase-keys.md) ^4.1.0
- [pg-query-stream](https://npm.io/package/pg-query-stream.md) ^1.0.0

## Recent versions

- 0.0.4 (latest) — 2017-09-10
- 0.0.3 — 2017-08-19
- 0.0.2 — 2017-07-22
- 0.0.1 — 2017-07-17

## README

# pg-telepods

> Takes the contents of one PostgreSQL table, applies a transformation function to each row and ensures a target table is kept in sync

## <a name="install"></a>Install
```bash
$ npm install pg-telepods --save
```

## <a name="usage"></a>Usage

```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.
  }
)
```

## <a name="test"></a>Testing

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
```


## <a name="license"></a>License
[MIT](https://github.com/wmfs/pg-telepods/blob/master/LICENSE)

---
_Source: https://npm.io/package/pg-telepods · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
