lib/handlers/get.js
function getJunctionTableFromModelAndRelatedColumn(model, parentTableName, relatedColumnTableName) {
  const junctionTableName = Object.keys(model.waterline.schema)
    .find(schemaName => {
      const tables = model.waterline.schema[schemaName].tables

      if (!tables) return false

      return tables[0] === parentTableName && tables[1] === relatedColumnTableName
    })

  if (!junctionTableName) return false

  const junctionTableSchema = model.waterline.schema[junctionTableName]
  const junctionTableCollection = model.waterline.collections[junctionTableName]

  return {
    tableName: junctionTableName,
    tables: junctionTableSchema.tables,
    collection: junctionTableCollection,
    columns: Object.keys(junctionTableCollection.attributes).filter(name => name !== "id")
  }
}
function getJunctionTableFromModelAndRelatedColumn(model, parentTableName, relatedColumnTableName) {
  const junctionTableName = Object.keys(model.waterline.schema)
    .find(schemaName => {
      const tables = model.waterline.schema[schemaName].tables

      if (!tables) return false

      return tables[0] === parentTableName && tables[1] === relatedColumnTableName
    })

  if (!junctionTableName) return false

  const junctionTableSchema = model.waterline.schema[junctionTableName]
  const junctionTableCollection = model.waterline.collections[junctionTableName]

  return {
    tableName: junctionTableName,
    tables: junctionTableSchema.tables,
    collection: junctionTableCollection,
    columns: Object.keys(junctionTableCollection.attributes).filter(name => name !== "id")
  }
}
function getJunctionTableFromModelAndRelatedColumn ( model , parentTableName , relatedColumnTableName ) { const junctionTableName = Object . keys ( model . waterline . schema ) . find ( schemaName => { const tables = model . waterline . schema [ schemaName ] . tables if ( ! tables ) return false return tables [ 0 ] === parentTableName && tables [ 1 ] === relatedColumnTableName } ) if ( ! junctionTableName ) return false const junctionTableSchema = model . waterline . schema [ junctionTableName ] const junctionTableCollection = model . waterline . collections [ junctionTableName ] return { tableName : junctionTableName , tables : junctionTableSchema . tables , collection : junctionTableCollection , columns : Object . keys ( junctionTableCollection . attributes ) . filter ( name => name !== "id" ) } }
Get the junction table waterline generates for
many-to-many related tables.

@param { Waterline.Collection } model to get schemas from
@param { string } parentTableName to check relationships
@param { string } relatedColumnTableName to check relationships
@return { Waterline.Collection | false } The junction table or undefined.
Get the junction table waterline generates for many - to - many related tables .