atomic_db.js
/**
	 * Executes the query
	 *
	 * @param String query
	 * @return Promise
	 */
Executes the query
@param String query
@return Promise
Executes the query @param String query @return Promise
query(query) {
		return new Promise((resolve, reject) => {
			const nonmaster = query.toLowerCase().match(/^(show)|(select)/), 
				connectionProcess = (err, conn) => {
					if (err) {
						console.log(err);
						reject(err);
					} else {
						conn.query(query, (err, rows, fields) => {
							conn.release();
							this.log(query, conn, err);
							if (err) {
								reject(err);
							} else {
								resolve({ rows: rows, fields: fields });
							}
						});
					}
				};
			if (!nonmaster) {
				this.cluster.getConnection('MASTER', connectionProcess);
			} else {
				this.cluster.getConnection(connectionProcess);
			}
		});
	}
query ( query ) { return new Promise ( ( resolve , reject ) => { const nonmaster = query . toLowerCase ( ) . match ( / ^(show)|(select) / ) , connectionProcess = ( err , conn ) => { if ( err ) { console . log ( err ) ; reject ( err ) ; } else { conn . query ( query , ( err , rows , fields ) => { conn . release ( ) ; this . log ( query , conn , err ) ; if ( err ) { reject ( err ) ; } else { resolve ( { rows : rows , fields : fields } ) ; } } ) ; } } ; if ( ! nonmaster ) { this . cluster . getConnection ( 'MASTER' , connectionProcess ) ; } else { this . cluster . getConnection ( connectionProcess ) ; } } ) ; }
Executes the query
 @param String query
 @return Promise
Executes the query @param String query @return Promise
//regex is used to figure out if this query is a read-only query //non read-only queries are sent to the master //read-only queries are routed betwixt master and slaves via round-robin