@wmfs/pg-address-matcher

A package to link two database tables by addresses

Usage no npm install needed!

<script type="module">
  import wmfsPgAddressMatcher from 'https://cdn.skypack.dev/@wmfs/pg-address-matcher';
</script>

README

pg-address-matcher

Tymly Package npm (scoped) CircleCI codecov CodeFactor Dependabot badge Commitizen friendly JavaScript Style Guide license

A package to link two database tables by addresses

Usage

const addressMatch = require('@wmfs/pg-address-matcher')

addressMatch(
    {
     source: {
       schema: 'link_test',
       table: 'food',
       id: 'food_id',
       type: 'bigint'
     },
     target: {
       schema: 'link_test',
       table: 'addressbase',
       id: 'address_id',
       type: 'bigint'
     },
     link: {
       schema: 'link_test_results',
       table: 'food_addressbase',
       map: {
         postcode: {
           source: 'postcode',
           target: 'postcode'
         },
         businessName: {
           source: ['business_name', 'address_line_1'],
           target: ['organisation_name', 'organisation', 'building_name']
         }
       }
     }
    }
)

The package will look at the options and try to match the records from the source table to the records from the target table and assign the id's given in the options to the link table.
The package currently matches on postcode and business name where the column names are indicated in the options provided.

Install

$ npm install pg-address-matcher --save

This package requires the database to have the "fuzzystrmatch" extension for Postgres which is achieved by:

CREATE EXTENSION "fuzzystrmatch";

License

MIT