Skip to content

A small library for syncing elastic search with mysql using Zong Ji

License

Notifications You must be signed in to change notification settings

thormengkheang/esmysqlsync

Repository files navigation

ESMySQLSync

Build Status Coverage Status

A small library for syncing elastic search with mysql using Zong Ji.

Installation

npm install esmysqlsync

Usage

const ESMySQLSync = require('./');

const app = new ESMySQLSync({
  mysql: {
    host: 'localhost',
    user: 'slave',
    password: 'password',
  },
  batch: 10, // default to 10
  index: ({ row, tableMap }) => {
    console.log(tableMap); // additional table data
    return { action: 'index', index: 'products', type: 'product_type', id: row.id, body: row };
  },
  update: ({ row }) => ({ action: 'update', index: 'products', type: 'product_type', id: row.after.id, body: row.after }),
  delete: ({ row }) => ({ action: 'delete', index: 'products', type: 'product_type', id: row.id }),
  success: res => console.log(res), // optional
  error: e => console.log(e), // optional
});

app.start({ startAtEnd: true });
console.log('Running');

About

A small library for syncing elastic search with mysql using Zong Ji

Resources

License

Stars

Watchers

Forks

Packages

No packages published