belongsToMany(Target, joinTableName, foreignKey, otherKey, foreignKeyTarget, otherKeyTarget) {
      return this._relation('belongsToMany', Target, {
        joinTableName,
        foreignKey,
        otherKey,
        foreignKeyTarget,
        otherKeyTarget
      }).init(this);
    }
Defines a many-to-many relation, where the current model is joined to one or more of a
`Target` model through another table. The default name for the joining table is the two
models' table names joined by an underscore, and ordered alphabetically. For example, a
`users` table and an `accounts` table would have a joining table named `accounts_users`.

The default key names in the joining table are the singular versions of the model table
names, followed by `_id` / `_{{{@link Model#idAttribute idAttribute}}}`. So in the above
example the columns in the joining table would be `user_id`, `account_id`, and `access`,
which is used as an example of how dynamic relations can be formed using different contexts.

To customize the keys or the {@link Model#tableName tableName} used for the join table, you
may specify them in the arguments to the function call:

    this.belongsToMany(Account, 'users_accounts', 'userId', 'accountId')

If you wish to create a belongsToMany association where the joining table has a primary key
and extra attributes in the model, you may create a `belongsToMany`
{@link Relation#through through} relation:

    const Doctor = bookshelf.model('Doctor', {
      patients() {
        return this.belongsToMany('Patient').through('Appointment')
      }
    })

    const Appointment = bookshelf.model('Appointment', {
      patient() {
        return this.belongsTo('Patient')
      },
      doctor() {
        return this.belongsTo('Doctor')
      }
    })

    const Patient = bookshelf.model('Patient', {
      doctors() {
        return this.belongsToMany('Doctor').through('Appointment')
      }
    })

Collections returned by a `belongsToMany` relation are decorated with several pivot helper
methods. If you need more information about these methods see
{@link Collection#attach attach}, {@link Collection#detach detach},
{@link Collection#updatePivot updatePivot} and {@link Collection#withPivot withPivot}.

@example
const Account = bookshelf.model('Account', {
  tableName: 'accounts'
})

const User = bookshelf.model('User', {
  tableName: 'users',
  allAccounts() {
    return this.belongsToMany('Account')
  },
  adminAccounts() {
    return this.belongsToMany('Account').query({where: {access: 'admin'}})
  },
  viewAccounts() {
    return this.belongsToMany('Account').query({where: {access: 'readonly'}})
  }
})

@method  Model#belongsToMany
@param {Model|string} Target
  Constructor of {@link Model} targeted by join. Can be a string specifying a previously registered model with
  {@link Bookshelf#model}.
@param {string} [joinTableName]
  Name of the joining table. Defaults to the two table names ordered alphabetically and
  joined by an underscore.
@param {string} [foreignKey]
  Foreign key in this model. By default, the `foreignKey` is assumed to be the singular form
  of this model's tableName, followed by `_id` / `_{{{@link Model#idAttribute idAttribute}}}`.
@param {string} [otherKey]
  Foreign key in the `Target` model. By default, this is assumed to be the singular form of
  the `Target` model's tableName, followed by `_id` /
  `_{{{@link Model#idAttribute idAttribute}}}`.
@param {string} [foreignKeyTarget]
  Column in this model's table which `foreignKey` references. This is only needed if it's not
  the default `id` / `{@link Model#idAttribute idAttribute}`.
@param {string} [otherKeyTarget]
  Column in the `Target` model's table which `otherKey` references. This is only needed, if
  it's not the expected default of the `Target` model's `id` /
  `{@link Model#idAttribute idAttribute}`.
@returns {Collection}
  A new empty collection that is decorated with extra pivot helper methods. See the
  description below for more info.