title: How do I add additional information to a Pivot (using Fluent)?
body: <p>In Vapor, we can create many-to-many relationships by creating a <code>Pivot&lt;U, T&gt;</code> object, where <code>U</code> and <code>T</code> are the models that we want to link together. So if I want to create a system where <code>User</code>s can have many <code>File</code>s and many <code>File</code>s can belong to many <code>User</code>s, I'd associate them like this:</p>
  
  <pre><code>var alice = User(name: "Alice")
  try! alice.save()
  var sales = File(name: "sales.xclx")
  try! sales.save()
  
  var pivot = Pivot&lt;User, File&gt;(alice, sales)
  try! pivot.save()
  </code></pre>
  
  <p>What I can't figure out for the life of me is how would I make a <code>Pivot&lt;User, File&gt;</code> contain additional information? For example, I'd like to know when was this file associated associated to Alice, or what permissions she has over it.</p>
  
  <p>On a Relational database, Fluent creates this table for the <code>Pivot&lt;User, File&gt;</code> type.</p>
  
  <pre><code>+---------+---------+------+-----+---------+----------------+
  | Field   | Type    | Null | Key | Default | Extra          |
  +---------+---------+------+-----+---------+----------------+
  | id      | int(11) | NO   | PRI | NULL    | auto_increment |
  | file_id | int(11) | NO   |     | NULL    |                |
  | user_id | int(11) | NO   |     | NULL    |                |
  +---------+---------+------+-----+---------+----------------+
  </code></pre>
  
  <p>But I'd like the ability to represent something like this:</p>
  
  <pre><code>+---------+---------+------+-----+---------+----------------+
  | Field   | Type    | Null | Key | Default | Extra          |
  +---------+---------+------+-----+---------+----------------+
  | id      | int(11) | NO   | PRI | NULL    | auto_increment |
  | file_id | int(11) | NO   |     | NULL    |                |
  | user_id | int(11) | NO   |     | NULL    |                |
  | date    | date    | NO   |     | NULL    |                |
  | perms   | varchar | NO   |     | READ    |                |
  +---------+---------+------+-----+---------+----------------+
  </code></pre>