Answers.Body: <blockquote>
    <p>I'm not calling .all(), so this is still an object, right?</p>
  </blockquote>
  
  <p>Nope.  When you execute the for loop, it will explicitly run the database query and return the array of results.  You're probably getting a deprecation error logged using that syntax as well since Craft wants you to use <code>{% for album in albums.all() %}</code></p>
  
  <p>See here in the docs:  <a href="https://docs.craftcms.com/v3/changes-in-craft-3.html#treating-queries-as-arrays" rel="noreferrer">https://docs.craftcms.com/v3/changes-in-craft-3.html#treating-queries-as-arrays</a></p>
  
  <p>If you want the first results for the album cover, you can use:</p>
  
  <pre><code>{% set albumCover = album.townPhotoAlbum[0] %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-12T21:27:56.357Z
Answers.Text: This answer is almost correct, but I think the actual issue is that the OP is using [eager loading](https://docs.craftcms.com/v3/dev/eager-loading-elements.html#app) (i.e. `.with(['townPhotoAlbum'])`), which is why `album.townPhotoAlbum` is an array and not an object (ElementQuery).
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-13T01:30:48.763Z
Answers.Text: @MatsMikkelRummelhoff "almost correct" is what I strive for. Completely overlooked the eager loading part.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-21T14:40:15.177Z
Answers.Text: Oh my gosh, `album.townPhotoAlbum[0]` is so obvious now. Thanks a bunch, Brad!!
Answers.UserDisplayName: Steven Thate
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-11T23:44:46.837Z
Answers.LastActivityDate: 2018-09-11T23:44:46.837Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am receiving the error message "Impossible to invoke a method ("limit") on an array," but I don't think I am working with an array! Here is why I think that...</p>
  
  <p>First I set an <code>albums</code> variable:</p>
  
  <p><code>{% set albums = craft.entries.section('townAlbums').with(['townPhotoAlbum']).relatedTo(entry) %}</code></p>
  
  <p>Then I loop through that object. I'm not calling <code>.all()</code>, so this is still an object, right?</p>
  
  <p><code>{% for album in albums %}</code></p>
  
  <p>Finally within this loop I am grabbing one image from the assets field <code>townPhotoAlbum</code> to use as a thumbnail or cover image for this album:</p>
  
  <p><code>{% set albumCover = album.townPhotoAlbum.limit(1) %}</code></p>
  
  <p><strong>Why is it complaining about using <code>.limit()</code> on an array when it appears as though I'm still working with an object? Or am I overlooking something woefully obvious?</strong></p>
  
  <p>Thanks!</p>
  
Tags: <entries><array><limit><elementquery>
Title: Impossible to invoke a method ("limit") on an array... but it's not an array?
ThreadText: # Impossible to invoke a method ("limit") on an array... but it's not an array?
  
  (Asked by: username_0 on 2018-09-10)
  
  I am receiving the error message "Impossible to invoke a method ("limit") on an array," but I don't think I am working with an array! Here is why I think that...
  
  First I set an `albums` variable:
  
  `{% set albums = craft.entries.section('townAlbums').with(['townPhotoAlbum']).relatedTo(entry) %}`
  
  Then I loop through that object. I'm not calling `.all()`, so this is still an object, right?
  
  `{% for album in albums %}`
  
  Finally within this loop I am grabbing one image from the assets field `townPhotoAlbum` to use as a thumbnail or cover image for this album:
  
  `{% set albumCover = album.townPhotoAlbum.limit(1) %}`
  
  **Why is it complaining about using `.limit()` on an array when it appears as though I'm still working with an object? Or am I overlooking something woefully obvious?**
  
  Thanks!
  
  **Tags:** entries, array, limit, elementquery
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-11. Score: 6 | Accepted answer
  
  > I'm not calling .all(), so this is still an object, right?
  
  Nope. When you execute the for loop, it will explicitly run the database query and return the array of results. You're probably getting a deprecation error logged using that syntax as well since Craft wants you to use `{% for album in albums.all() %}`
  
  See here in the docs: <https://docs.craftcms.com/v3/changes-in-craft-3.html#treating-queries-as-arrays>
  
  If you want the first results for the album cover, you can use:
  
  ```
  {% set albumCover = album.townPhotoAlbum[0] %}
  
  ```
  
  > **Comments:**
  > **username_2**: This answer is almost correct, but I think the actual issue is that the OP is using [eager loading](https://docs.craftcms.com/v3/dev/eager-loading-elements.html#app) (i.e. `.with(['townPhotoAlbum'])`), which is why `album.townPhotoAlbum` is an array and not an object (ElementQuery).  
  > **username_1**: @username_2 "almost correct" is what I strive for. Completely overlooked the eager loading part.  
  > **username_0**: Oh my gosh, `album.townPhotoAlbum[0]` is so obvious now. Thanks a bunch, username_1!!  
  
  ---
  
  