docs: function unlinkModel (controller, args) {
      // get model from controller
      var model = controller.model
      // get primary record from args
      var primaryRecord = args[model.name]
      // get relation by name
      var relation = model.relation(args.relation)
      // require relation with via
      if (!defined(relation) || !defined(relation.viaModel)) {
          httpError(400, 'invalid relation')
      }
      // via model must support delete
      if (!defined(relation.viaModel.columns)) {
          httpError(400, 'unlink not supported for ${relation.viaModel.name}')
      }
      // get related record from args
      var relatedRecord = args[relation.model.name]
      // build query to select relation entries from via table - there should
      // usually be only 1 but if there are multiple delete them all
      var queryArgs = {
          session: args.session,
          where: {},
      }
      // add primary model id to where query
      queryArgs.where[relation.viaModelIdColumn] = primaryRecord.raw[relation.modelIdColumn]
      // add related model id to where query
      queryArgs.where[relation.viaRelationIdColumn] = relatedRecord.raw[relation.relationIdColumn]
      // do query
      return relation.viaModel.query(queryArgs).then(result => {
          // delete each record
          return result.each(record => record.delete())
      })
      // take appropriate action on success
      .then(() => {
          // if json then return raw data
          if (args.json) {
              return {success: true}
          }
          // if html then redirect
          else {
              httpRedirect(args.redirect || args.referrer)
          }
      })
  }