src/Select/Select.js
/**
	 * Fetch sibling data and splice it into the given result set
	 * @param {Array} queries  The final SQL statements that were executed
	 */
Fetch sibling data and splice it into the given result set
@param {Array} queries  The final SQL statements that were executed
Fetch sibling data and splice it into the given result set @param { Array } queries The final SQL statements that were executed
async _spliceSiblingData(records) {
		if (this._siblings.length === 0 || records.length === 0) {
			return [];
		}
		const sqlQueries = [];
		for (const { property, query } of this._siblings) {
			const onColumn = Select._extractBindingName(query.toString());
			const values = records.map(record => record[onColumn]);
			query.bind(onColumn, values);
			const { queries, results, fields } = await query.fetch();
			const indexed = {};
			const firstField = fields[0].name;
			results.forEach(result => {
				const key = result[firstField];
				indexed[key] = result;
			});
			records.forEach(record => {
				record[property] = indexed[record[onColumn]];
			});
			sqlQueries.push(...queries);
		}
		return sqlQueries;
	}
async _spliceSiblingData ( records ) { if ( this . _siblings . length === 0 || records . length === 0 ) { return [ ] ; } const sqlQueries = [ ] ; for ( const { property , query } of this . _siblings ) { const onColumn = Select . _extractBindingName ( query . toString ( ) ) ; const values = records . map ( record => record [ onColumn ] ) ; query . bind ( onColumn , values ) ; const { queries , results , fields } = await query . fetch ( ) ; const indexed = { } ; const firstField = fields [ 0 ] . name ; results . forEach ( result => { const key = result [ firstField ] ; indexed [ key ] = result ; } ) ; records . forEach ( record => { record [ property ] = indexed [ record [ onColumn ] ] ; } ) ; sqlQueries . push ( ... queries ) ; } return sqlQueries ; }
Fetch sibling data and splice it into the given result set
 @param {Array} queries  The final SQL statements that were executed
Fetch sibling data and splice it into the given result set @param { Array } queries The final SQL statements that were executed