src/Select/Select.js
/**
	 * Fetch child data and splice it into the given result set
	 * @param {Array} queries  The final SQL statements that were executed
	 */
Fetch child data and splice it into the given result set
@param {Array} queries  The final SQL statements that were executed
Fetch child data and splice it into the given result set @param { Array } queries The final SQL statements that were executed
async _spliceChildData(records) {
		if (this._children.length === 0 || records.length === 0) {
			return [];
		}
		const sqlQueries = [];
		for (const { property, query } of this._children) {
			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 firstField = fields[0].name;
			const grouped = {};
			results.forEach(result => {
				const key = result[firstField];
				if (!grouped[key]) {
					grouped[key] = [];
				}
				grouped[key].push(result);
			});
			records.forEach(record => {
				record[property] = grouped[record[onColumn]] || [];
			});
			sqlQueries.push(...queries);
		}
		return sqlQueries;
	}
async _spliceChildData ( records ) { if ( this . _children . length === 0 || records . length === 0 ) { return [ ] ; } const sqlQueries = [ ] ; for ( const { property , query } of this . _children ) { 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 firstField = fields [ 0 ] . name ; const grouped = { } ; results . forEach ( result => { const key = result [ firstField ] ; if ( ! grouped [ key ] ) { grouped [ key ] = [ ] ; } grouped [ key ] . push ( result ) ; } ) ; records . forEach ( record => { record [ property ] = grouped [ record [ onColumn ] ] || [ ] ; } ) ; sqlQueries . push ( ... queries ) ; } return sqlQueries ; }
Fetch child data and splice it into the given result set
 @param {Array} queries  The final SQL statements that were executed
Fetch child data and splice it into the given result set @param { Array } queries The final SQL statements that were executed