code: function findRelatedCollectionIDsByCriteria(models, junctionTable, subQueryCriteria) {
    const subQueryTable = models[junctionTable.tables[1]]
  
    return subQueryTable
      .find({
        select: ["id"],
        where: subQueryCriteria
      })
      .then(idObjects => idObjects.map(idObject => idObject.id))
      .then(ids => {
        const junctionTableQuery = {}
  
        junctionTableQuery[junctionTable.columns[0]] = ids
  
        return junctionTable.collection.find({
          select: [junctionTable.columns[1]],
          where: junctionTableQuery
        })
          .then(idObjects => idObjects.map(idObject => idObject[junctionTable.columns[1]]))
      })
  }
docs: Get all the ids for the {target} model
  based on a subquery.
  
  @param { Waterline.Collection[] } models to query against.
  @param { { tableName: string, collection: Waterline.Collection, columns: string[], tables: string[] } } junctionTable to get intermediary IDs from.
  @param { Object } subQueryCriteria object to query the related table with.
  @return { Promise<Object[]> } unresolved promise with the result sets.