| 19 | }; |
| 20 | |
| 21 | var eagerQuery = function (association, opts, keys, cb) { |
| 22 | var desiredKey = Object.keys(association.field); |
| 23 | var assocKey = Object.keys(association.mergeAssocId); |
| 24 | |
| 25 | var where = {}; |
| 26 | where[desiredKey] = keys; |
| 27 | |
| 28 | var query = this.query.select() |
| 29 | .from(association.model.table) |
| 30 | .select(opts.only) |
| 31 | .from(association.mergeTable, assocKey, opts.keys) |
| 32 | .select(desiredKey).as("$p") |
| 33 | .where(association.mergeTable, where) |
| 34 | .build(); |
| 35 | |
| 36 | this.execSimpleQuery(query, cb); |
| 37 | }; |
| 38 | |
| 39 | module.exports = { |
| 40 | generateQuery: generateQuery, |