title: Phoenix Framework - Index should show message where state == "new"
body: <p>I'm looking to show only messages with a state of "new" in the def index. </p>
  
  <p>Here is the working code I have to show all messages:</p>
  
  <pre><code>def index(conn, _params) do
    messages = Repo.all(Message)
    render(conn, "index.json", messages: messages)
  end
  </code></pre>
  
  <p>I'm trying to filter the messages to only show ones that have a state of "new". Here is the code I tried unsuccessfully:</p>
  
  <pre><code>def index(conn, _params) do
    messages = Repo.all(Message
    |&gt; where([message], message.state == "sent"))
    render(conn, "index.json", messages: messages)
  end
  </code></pre>