atomic_db.js
/**
	 * Connects to DB and builds out the cluster
	 */
Connects to DB and builds out the cluster
Connects to DB and builds out the cluster
connect() {
		const mysql = require("mysql"),
			cluster = mysql.createPoolCluster({
				restoreNodeTimeout: 1000
			}),
			hasSlaves = (typeof this.config.mysql.slaves !== "undefined" && this.config.mysql.slaves instanceof Array);
		cluster.add('MASTER', this.config.mysql.master);
		if (!hasSlaves) {
			this.config.mysql.slaves = [];
		}
		this.config.mysql.slaves.forEach((slave, index) => {
			cluster.add(`SLAVE${(index+1)}`, slave);
		});
		this.cluster = cluster;
	}
connect ( ) { const mysql = require ( "mysql" ) , cluster = mysql . createPoolCluster ( { restoreNodeTimeout : 1000 } ) , hasSlaves = ( typeof this . config . mysql . slaves !== "undefined" && this . config . mysql . slaves instanceof Array ) ; cluster . add ( 'MASTER' , this . config . mysql . master ) ; if ( ! hasSlaves ) { this . config . mysql . slaves = [ ] ; } this . config . mysql . slaves . forEach ( ( slave , index ) => { cluster . add ( ` ${ ( index + 1 ) } ` , slave ) ; } ) ; this . cluster = cluster ; }
Connects to DB and builds out the cluster
Connects to DB and builds out the cluster