bp-mysql-sync
v0.0.3
Published
## Installation Installing the package using NPM: ``` npm i bp-mysql-sync ```
Downloads
1
Readme
MySQL-Sync
Installation
Installing the package using NPM:
npm i bp-mysql-sync
Installing the package using Yarn:
yarn add bp-mysql-sync
Usage
Start by including the package.
const {sync} = require('bp-mysql-sync');
Setup MySQL credentials to an existing database. These settings allow any default settings from the mysql
package.
const settings = {
host : 'MYSQL_HOST',
user : 'MYSQL_USER',
password : 'MYSQL_PASSWORD',
database : 'MYSQL_DATABASE'
};
Get the data formatted as an array of columns.
let cars = [
{
licence_number: 'ABC123',
name: 'Volvo V70',
milage: 19000
},
{
licence_number: 'XYZ987',
name: 'SAAB 93',
milage: 7256
},
];
Call the sync function:
await sync(settings, 'cars', 'licence_number', cars)
Decleration:
sync(DATABASE_SETTINGS, TABLE_NAME, UNIQUE_COLUMN_NAME, DATA_ARRAY)
Changelog
0.0.3
- Fix truncation error.